multiple files upload

See all posts See thread Reply

Re: multiple files upload new!
by colin, 16 years, 9 months ago
Read the FAQ again. If you do multiple uploads, you have to change the $_FILES array.

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

Then you can use $files rather than $_FILES in your code. Note that you can trim out all non-uploaded images in the code above.Reply