I wrote a small gallery script, but I need some help with it - it always worked fine so far, but right now I tested uploading some pictures I took with my digicam without editing the image or name, and I got a loong error page. Then I tried uploading a unedited pictures from a friend's digicam - which also didn't work.
Then I tested uploading a wallpaper I made, and some other stuff, and that worked totally fine! I also tested uploading a resized & edited pic which I took with my digicam, which also worked totally fine!
Help! What is this? Why doesn't my script upload unedited digicam pictures???
This is the part of the script which does the uploading:
$uploadedfile = $_FILES['photo']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height) = getimagesize($uploadedfile);
if ($width > $maxwidth) {
$newwidth = $maxwidth;
$newheight = ($height/$width)*$newwidth;
} else {
$newwidth = $width;
$newheight = ($height/$width)*$newwidth;
}
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = $dirpath.$gal_id."/".$_FILES['photo']['name'];
imagejpeg($tmp,$filename,100);
#__ thumb _________________________________________________________
$uploadedthumb = $_FILES['photo']['tmp_name'];
$srcthumb = imagecreatefromjpeg($uploadedthumb);
list($widththumb,$heightthumb) = getimagesize($uploadedthumb);
$newwidththumb = 100;
$newheightthumb = 75;
$src_top = ($src_height / 2) - ($dst_height / 2);
$src_left = ($src_width / 2) - ($dst_width / 2);
$tmpthumb = imagecreatetruecolor($newwidththumb,$newheightthumb);
imagecopyresampled($tmpthumb,$srcthumb,0,0,$src_top,$src_left,$newwidththumb,$newheightthumb,$widththumb,$heightthumb);
$thumbname = $dirpath.$gal_id."/zth_".$_FILES['photo']['name'];
imagejpeg($tmpthumb,$thumbname,100);
#___________________________________________________________________
imagedestroy($srcthumb);
imagedestroy($tmpthumb);
imagedestroy($src);
imagedestroy($tmp);
And this is the error page I get with unedited pics:
Warning: Division by zero in /www/htdocs/gallery/gal_postphotos.php on line 16
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos.php on line 18
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 19
Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 21
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 34
Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 40
Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 42
Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos.php on line 43