Reply to Re: Processing in an array?

Re: Processing in an array? new!
by colin, 16 years, 4 months ago
The class itself handles one uploaded file at a time. In case of multiple uploads, the $_FILES array has a different structure, so you need first to re-structure it so it can be looped through, and each element of the array used to instanciate the class.

$files = array();
foreach ($_FILES['art_img'] as $k => $l) {
 foreach ($l as $i => $v) {
 if (!array_key_exists($i, $files)) 
   $files[$i] = array();
   $files[$i][$k] = $v;
 }
}
and then:
foreach ($files as $file) {
  $handle = new Upload($file);
  if ($handle->uploaded) {
    $handle->Process("./");
    if ($handle->processed) {
      echo 'OK';
      // add your data in the database here
    } else {
      echo 'Error: ' . $handle->error;
    }
  } else {
    echo 'Error: ' . $handle->error;
  }
  unset($handle);
}
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