Can someone help me modify this code? I want it to create a thumbnail of the original image, but I don’t want to save the original image, just the thumbnail, and delete the original image.
[code=php]function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality = 60){
$details = getimagesize(“$imageDirectory/$imageName”) or die(‘<div class=”container”>
<div class=”content”>
Please only upload images.
<p>
<a class=”bod” href=”user.php?login=upload”>Uploads</a>
</p>
</div>
</div>’);
$type = preg_replace(‘@^.+(?<=/)(.+)$@’, ‘$1’, $details[‘mime’]);
eval(‘$srcImg = imagecreatefrom’.$type.'(“$imageDirectory/$imageName”);’);
$thumbHeight = $details[1] * ($thumbWidth / $details[0]);
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $details[0], $details[1]);
eval(‘image’.$type.'($thumbImg, “$thumbDirectory/$imageName”‘.(($type==’jpeg’)?’, $quality’:”).’);’);
imagedestroy($srcImg);
imagedestroy($thumbImg);
}
foreach ($_FILES[“pictures”][“error”] as $key => $error)
{
if($error === 0)
{
$filename = time().$_FILES[“upload_img”][“name”][$key];
move_uploaded_file($_FILES[“upload_img”][“tmp_name”][$key], “images/user_images/$filename”);
createThumbnail(“images/user_images”, “$filename”, “images/user_images”, 350);
mysql_query(“INSERT INTO images(`userid`, `filename`) VALUES (‘$row[userid]’, ‘$filename’)”);
}
}