Reply to Multiple image upload filenames

Multiple image upload filenames new!
by Matt, 14 years, 8 months ago
Hi,

I have successfully implemented this class to upload 6 images as per the examples given in the FAQ on this site and also storing the correct filename in my database table. My question relates to an update record page that I have, that allows for the changing of images associated with a record. As each image name is stored in a separate field in the table I am having difficulty updating the correct field with the correct image name. This I believe is down to the fact that not all images are being replaced and therefore the $_FILES array has empty records depending on which images were selected to be changed. Having carried out some testing on the contents of the arrays during this process, I am still none the wiser so I am hoping that someone maybe able to point me in the right direction.

Here is my code:
// create an array here to hold file names
$uploaded = array();

foreach ($files as $file) {
  $handle = new Upload($file);
  if ($handle->uploaded) {
    // create a little array for this set of pictures
    $this_upload = array();
      
    $handle->file_safe_name 	= true;
    $handle->file_auto_rename   = true;
	$handle->file_max_size 		= '512000';
	$handle->allowed			= array('image/jpeg', 'image/jpg');
    $handle->Process($dir_dest);
    
    if ($handle->processed) {
      echo $handle->file_dst_name;
      // store the image filename  
      $this_upload['image'] = $handle->file_dst_name;
    } else {
      echo 'error : ' . $handle->error;
    }
    
    // add this set of pictures to the main array
    $uploaded[] = $this_upload;
  }
}

Many thanks for your help.

MattReply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important