Hi,
I'm writing a page where the user can upload 2 images, and I need to create a thumbnail from these. The problem I am having is that the first thumbnail is created properly, the second thumbnail is created from the firstpicture, not the second, despite the code being reused. Can anybody help, This is my first time using PHP after several years of developing for ASP..
Code...
if (is_uploaded_file($file[0][0])) {
move_uploaded_file($file[0][0], "/www/server/images/$number.jpg");
$filename = "$number.jpg";
print "File Uploaded";
print "<br><img src=\"images/$filename\"><p>";
$filenamethm = $number . "a.jpg";
$imgsrc = imagecreatefromjpeg("/www/server/images/$filename");
$newwidth = $thumbsize;
$newheight = imagesy($imgsrc) * $newwidth / imagesx($imgsrc);
echo "$newheight";
$destimage = imagecreate($newwidth,$newheight);
imagecopyresized($destimage,$imgsrc,0,0,0,0,$newwidth,$newheight,imagesx($imgsrc),imagesy($imgsrc));
imagejpeg($destimage, "/www/server/images/$filenamethm");
print "<img src=\"$filenamethm\"><p>\n";
}
$secondpic = $number . "b.jpg";
echo "$secondpic<br>";
if (is_uploaded_file($file[1][0])) {
move_uploaded_file($file[1][0], "/www/server/image/$secondpic");
$filenameb = $secondpic;
$filenamethmb = "a" . $filenameb;
$imgsrcb = imagecreatefromjpeg("/www/server/image/$filenameb");
$newwidthb = $thumbsizeb;
$newheightb = imagesy($imgsrcb) * $newwidthb / imagesx($imgsrcb);
$destimageb = imagecreate($newwidthb,$newheightb);
imagecopyresized($destimageb,$imgsrcb,0,0,0,0,$newwidthb,$newheightb,imagesx($imgsrcb),imagesy($imgsrcb));
imagejpeg($destimage, "/www/server/image/$filenamethmb");
print "<img src=\"image/$filenamethmb\">\n";
}
?>