Uploading Images Filename

Hi,

Thanks in advance for any assistance with a script that was working fine yesterday and seems to have fallen over for reasons I can’t get a fix on.

Script should allow me to upload images and save a copy in three widths.

Excerpt from script:



ShowProduct ($product_id);
$full_size_image_width=580;
$featured_size_image_width=290;
$small_image_width=200;
$new_image_id=GetNewImageID ();
   if( isset($_POST['submit']) ) {
$image_count=ImageCount ($product_id, $Images_Unique_Ref);
   if ($image_count==0) {
      $image = new SimpleImage();
      $image->load($_FILES['uploaded_image']['tmp_name']);
      $image->resizeToWidth($full_size_image_width);
	  $image->save('../dev/product_images/full_size/'.$new_image_id.'.jpg');
      $image->resizeToWidth($featured_size_image_width);
	  $image->save('../dev/product_images/featured_size/'.$new_image_id.'.jpg');
      $image->resizeToWidth($small_image_width);
	  $image->save('../dev/product_images/reduced_size/'.$new_image_id.'.jpg');
	InsertNewImageID ($new_image_id, $product_id, $Images_Unique_Ref);
	}


Excerpt from class



class SimpleImage {
   
   var $image;
   var $image_type;
 
   function load($filename) {
      $image_info = getimagesize($filename);
      $this->image_type = $image_info[2];
      if( $this->image_type == IMAGETYPE_JPEG ) {
         $this->image = imagecreatefromjpeg($filename);
      } elseif( $this->image_type == IMAGETYPE_GIF ) {
         $this->image = imagecreatefromgif($filename);
      } elseif( $this->image_type == IMAGETYPE_PNG ) {
         $this->image = imagecreatefrompng($filename);
      }
   }


As I say, have had it working but now getting error messages. First is:

Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in

There are other messages but I think the rest are all arising from this failure to get a filename to work on the uploaded file.

Any ideas would be gratefully received.

check $_FILES[‘uploaded_image’][‘error’] for errors.
And $_FILES array structure going to be different if more than 1 image were uploaded.
I’d suggest to do
print_r($_FILES);
in this case

Thanks Shrapnel,

Appreciate you taking the time. I’ve just done a bit of testing and it seems to be a problem with the size of the images I am using today. Yesterdays successful test run was on smaller sized images and have got it working by first reducing before uploading. Don’t know if the problem is a maximum size / width or filesize or why this would cause such problems.

just put this line in your code
print_r($_FILES);
and study output.
if there is anything in the [‘error’] field, manual can explain the code:
http://php.net/manual/en/features.file-upload.errors.php
Hope it helps.