So here I go again,
I have a very nice image upload script lent to me by a friend. except the last time it was implemented was on a php3 server.
So, heres the deal. I can't seem to re-phrase the file types to get it to want to re-create the image.
here are the errors - notice they are all about "argument is not a valid image resource...." what ?
Following the errors will be a snippet from the script where I think the specification needs to be made good
----warnings/ errors ----
Warning: Division by zero in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 46
Warning: imagecreate(): Invalid image dimensions in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 50
Warning: imagesx(): supplied argument is not a valid Image resource in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 52
Warning: imagesy(): supplied argument is not a valid Image resource in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 52
Warning: imagecopyresized(): supplied argument is not a valid Image resource in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 52
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/popstart/www/www/dbase/admin/do_addrecord.php on line 53
-------------- end warnings/ errors/
okay heres the code;
------------------in do_addrecord.php
if ($POST[image]){
// GENERATE RANDOM NAME
include 'random_name.php'; <---***see below
$rand_base = ranname();
$POST[rand_name] = "$rand_base.jpg";
// resize and upload image
$file = $FILES["image"]["name"];
$image = $FILES["image"]["tmp_name"];
$type = $_FILES["image"]["type"];
$image_dir = "images";
$dest = "../images/$rand_name";
$imgsize = GetImageSize($image);
$width = $imgsize[0];
$height = $imgsize[1];
$new_width = "200";
$new_height = ceil($new_width * $height / $width);
// resize
$im = ImageCreateFromJPEG($image);
$new_im = ImageCreate($new_width,$new_height);
ImageCopyResized($new_im,$im,0,0,0,0,$new_width, $new_height,ImageSX($im),ImageSY($im));
ImageJPEG($new_im,$dest,75);
};