Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var canvas = document.getElementById("theCanvas");
- var img = canvas.toDataURL("image/png");
- $.ajax({
- type: 'POST',
- url: 'http://********/ImageUpload.php',params: {img: img},
- success: function (msg)
- {
- alert("Done, Picture Uploaded.");
- }
- });
- <?php
- define('UPLOAD_DIR', '/pic');
- $img = $_POST['img'];
- $img = str_replace('data:image/png;base64,', '', $img);
- $img = str_replace(' ', '+', $img);
- $data = base64_decode($img);
- $file = UPLOAD_DIR . uniqid() . '.png';
- $success = file_put_contents($file, $data);
- print $success ? $file : 'Unable to save the file.';
- ?>
- $query = "INSERT INTO item(title, description, price) values('".$_GET['title']."', '".$_GET['description']."', ".$_GET['price'].")";
- $stmt = $conn->query($query);
- $item_id = mysql_insert_id($conn);
- $query = "INSERT INTO item_pic(path, item_id) values('".$_GET['path']."', '".$_GET['item_id'].")";
- $stmt = $conn->query($query);
- $.ajax({
- type: "POST",
- url: "http://*****/*****/AddProduct/create.php?title="+ ($("#myTitle").val())+"&description="
- +$("#myDesc").val()+"&price="+$("#myPrice").val(),
- success: function(data){
- alert("inserted");
- }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement