Reply to Re: Multiple image upload filenames

Re: Multiple image upload filenames new!
by Matt, 14 years, 2 months ago
Apologies, I missed off one part of the code. Thanks

//initialize new images to be uploaded
$files = array();
foreach ($_FILES['image'] as $k => $l) {
  foreach ($l as $i => $v) {
    if (!array_key_exists($i, $files))
      $files[$i] = array();
    $files[$i][$k] = $v;
  }
}

// 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;
  }
}
Reply

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