Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting Thumbnail into Database
    text
    copied!<p>I have successfully added the original image into my imgs/ folder and also onto the server. But I'm wanting to add the thumbnail into the database. I've added it into the imgs/ folder but can't seem to find away to insert it into the database. </p> <p>This is the final bit of code that is used to crop the img and insert it to the folder. </p> <p>I need to insert it into the database also so I can call on it for the $_SESSION User and the Users friend as I have profiles. </p> <pre><code>if (isset($_POST["upload_thumbnail"]) &amp;&amp; strlen($large_photo_exists)&gt;0) { //Get the new coordinates to crop the image. $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; //Scale the image to the thumb_width set above $scale = $thumb_width/$w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale); //Reload the page again to view the thumbnail header("location:".$_SERVER["PHP_SELF"]); exit(); } if(isset($_GET['a'])){ if ($_GET['a']=="delete"){ if (file_exists($large_image_location)) { unlink($large_image_location); } if (file_exists($thumb_image_location)) { unlink($thumb_image_location); $creator_id = $_SESSION['id']; $sql = "UPDATE users SET user_pic_small='".$img."' WHERE id=$creator_id"; $sql2 = "INSERT INTO userphotos(photo_ownerid,photo_ispublic, photo_name, photo_caption, photo_imagedata) VALUES ($creator_id,1,'Profile Picture','Profile Picture','$img')"; // insert the image if(!mysql_query($sql)) { echo "Fail. It broke."; }else{ $c=mysql_query($sql2); echo "&lt;script&gt; parent.alert('Image Uploaded','',1000);&lt;/script&gt;"; } } } } </code></pre> <p>Hope someone can help. Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload