How to upload multiple files using PHP

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
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

How to upload multiple files using PHP

Post by dream2rule »

Hello All,

I would like to know how do i upload multiple files in a form. In the form, there are around 10-12 fields to browse files and when i click on the submit button i want to store all the uploaded files into the database and also i want to retrieve them.

Can anyone help me with the code?

Thanks and Regards,

Dream2rule
(a NOOB)
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Just as you would upload a single file :wink:

P.S Don't store files in the database. Instead, store in the database the file's path.
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Post by dream2rule »

thanks oren for your reply...

Yea i meant that i would store the file path in the database.

Can you give me an example to retrieve multiple files that have been uploaded.

Thanks and Regards
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's an example in the manual
http://www.php.net/manual/en/features.file-upload.php wrote:Example 38.3. Uploading array of files
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Post by dream2rule »

hie volka.. that script isn't working :( :( :(

any other means?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

It's working fine for me.
What error message do you get? If you don't get an error message please change the settings of error_reporting and display_errors to

Code: Select all

error_reporting=E_ALL
display_errors=On
in the php.ini of your test/development server.

Code: Select all

<?php echo 'ini: ', get_cfg_var('cfg_file_path'); ?>
tells you which file you have to change.
You might have to restart the webserver.
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Post by dream2rule »

thanks volka.. i hope this works..!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

It will not "fix" the script. But errors and warning messages should be display in the browser then.
Post Reply