This is a discussion on "Multiple file uploads" within the PHP Forum section. This forum, and the thread "Multiple file uploads are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Multiple file uploads
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Multiple file uploads
Hi i am trying to set up a mutliple file upload PHP form but cannot get it to work for more than one upload. My code is as follows:
FORM CODE:
Thanks Robert |
|
|
|
#2
|
||||
|
||||
|
Re: Multiple file uploads
you have to name the file inputs differently
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#3
|
|||
|
|||
|
Re: Multiple file uploads
Sorry i have tried that but it didn't work so i reverted back to that one.
Any other suggestions? Thanks Robert |
|
#4
|
|||
|
|||
|
Re: Multiple file uploads
There are two reasons why it's not working.
alexgeek is right, in your html you have to change the name attribute to: userfile userfile2 userfile3... on the php side of things, you are saying, in english: if the first file is saved, then don't worry about the other files you're almost there, you just need to replace all the "elseif's" in the code below with with "if". Also while you're at it, you should use $_FILES intstead of $HTTP_POST_FILES as it is depreceated.
Last edited by jimz; Sep 6th, 2007 at 08:48. |
|
#5
|
||||
|
||||
|
Re: Multiple file uploads
You could probably change your code to be quite a bit more graceful and cut back on your duplication.
Changing the names of the file inputs to <input type="file" name="userfile[]" tabindex="26" size="16" /> and adding an input like <input type="hidden" name="max_uploads_allowed" value="8" /> Changing the value to the amount of upload inputs on your page. Changing the name of the files in this manner will mean PHP will create an array in the superglobal $HTTP_POST_FILES['username'] or $_FILES With an enumerated array that you can cycle through like
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#6
|
|||
|
|||
|
Re: Multiple file uploads
I have tried that but when i click submit it just loads a blank page.
|