Handle multiple file upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Handle multiple file upload

Post 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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Handle multiple file upload

Post by Jonah Bron »

Loop over $_FILES

Code: Select all

foreach ($_FILES as $file) {
    // do something with $file
}
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Re: Handle multiple file upload

Post 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']
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Handle multiple file upload

Post by Jonah Bron »

Yes.
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Re: Handle multiple file upload

Post by TonsOfFun »

Perfect. Thanks for the help.
Post Reply