Page 1 of 1

Handle multiple file upload

Posted: Mon Nov 01, 2010 6:43 pm
by TonsOfFun
I have an upload form that allows the user to upload multiple files but I don't know how to handle it once the form is submitted.

I am assuming a foreach loop but I don't know how to implement that.

The fields will be name image_1, image_2, etc.

Any help would be appreciated.

Re: Handle multiple file upload

Posted: Mon Nov 01, 2010 6:52 pm
by Jonah Bron
Loop over $_FILES

Code: Select all

foreach ($_FILES as $file) {
    // do something with $file
}

Re: Handle multiple file upload

Posted: Mon Nov 01, 2010 7:02 pm
by TonsOfFun
Jonah Bron wrote:Loop over $_FILES

Code: Select all

foreach ($_FILES as $file) {
    // do something with $file
}
With this, would $file become an array with the tmp_name, size, and type and all that?

ie:

Code: Select all

$file['tmp_name']

Re: Handle multiple file upload

Posted: Mon Nov 01, 2010 7:05 pm
by Jonah Bron
Yes.

Re: Handle multiple file upload

Posted: Mon Nov 01, 2010 7:12 pm
by TonsOfFun
Perfect. Thanks for the help.