I have problems with multiple upload

See all posts Reply

I have problems with multiple upload new!
by Alex, 11 years, 8 months ago
require'class.upload.php';

$files = array();
foreach ($_FILES['image_field'] as $k => $l) {
 foreach ($l as $i => $v) {
 if (!array_key_exists($i, $files))
   $files[$i] = array();
   $files[$i][$k] = $v;
 }
}

foreach ($files as $file) {
  $handle = new Upload($file);
  if ($handle->uploaded) {
    $handle->Process("C:\Users\ALEX\Desktop\images");
    if ($handle->processed) {
      echo 'OK';
    } else {
      echo 'Error: ' . $handle->error;
    }
  } else {
    echo 'Error: ' . $handle->error;
  }
  unset($handle);
}


This is the code that i'm using for the upload.php file
When i upload an image it says Warning: Invalid argument supplied for foreach(), and it is this line of the code foreach ($l as $i => $v)

What should i do ?Reply
Re: I have problems with multiple upload new!
by colin, 11 years, 8 months ago
Check if your form is functioning properly. If you do a vardump() of $_FILES, what do you see? In any case, you need to make sure that your arrays are correct.Reply