Image

Imagegloomylight wrote in Imagephp

Image upload with resizing and additional thumbnail creation

Hi guys, since I'm a PHP novice I need some help with this script. I have a perfectly working script for uploading an image with resizing, *BUT* I need a script that takes the same image from the form a second time and creates a thumbnail from that. So the image would be uploaded twice - once as thumbnail and once as the original (resized). How exactly can that be done?

Thank you so much in advance :=)


This is the current script;

if ($uploadfile != "") {

$uploadedfile = $_FILES['uploadfile']['tmp_name'];


$src = imagecreatefromjpeg($uploadedfile);


list($width,$height)=getimagesize($uploadedfile);


$newwidth = 500;

$newheight = ($height/$width)*500;
$tmp = imagecreatetruecolor($newwidth,$newheight);


imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);


$filename = "/www/dir/". $_FILES['uploadfile']['name'];
imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp);


// for the db
$foto = "dir/". $_FILES['uploadfile']['name'];
}