uploading multiple files - help needed

Ok here’s my predicament.

At work one of my tasks for the site (being created in php) is to create a file uploader where people can select files to upload to the site. The problem is - with this site a user could potentially be wanting to upload over 100 files at any one time, maybe several hundred.

However as I’m sure you know - html file uploaders only allow one file to be selected at once… so for over 100 files this would be incredibly time consuming. Then I thought if there’s a list of files entered into a text box it would be possible to preload lots of file fields with this data - but nope it seems like you’re not allowed to use the value tag to set file fields like you are with normal text inputs.

Does anybody know of a way this could be implemented? Or do you know of any third party scripts that would work? I’m starting to run out of ideas.

I looked around for flash applets as some sites use these but when i went to select a large selection of files they all kept just saying “sorry… too many files”


The way I would go about this would be one of 2 ways…

  1. Have a text box on the upload page where the user can set how many files they would like to update. So say the enter 25 in this field and click the update button it would then put in 25 separate upload boxes.

I would just run a for loop on the value they entered. You will need to some validation to make sure they are entering a number and probably want to set a max number they can enter as well.

Then for each iteration of the for loop have it ouput a file field and give the name like

This will create an array called file. Then you can just for loop through it and do the appropriate work on each key in the array.

2. The only other way I could think of would be to statically put out a certain amount of fields, then just allow for the user, once they upload a bunch, to go back and upload a bunch more. Just keep letting the go back and enter more until they finish. All the same principles from the above suggestion apply here as well.

Thanks. I may have to have that as a backup option. On another forum I was pointed in the direction of a couple of java applets but java applets are restricted on our network and probably quite a few others too for security reasons - and with a user uploading over 100 files at a time most of the time this could get a bit repetitive.

What I’m thinking at the moment is

  1. java applet
    with either
  2. zip uploads in normal file box
  3. ftp uploading
    as a backup

Although if anybody has any better suggestions I’m all ears.

This is annoying though. I mean… I can understand the security aspect of not allowing file fields to be preset… but you’d think they would have a workaround so if a user for example had a file list of 100 files and sent that to a script it would allow file fields to be preset or something. That was my original idea but alas it won’t work dammit.

Sorry for multiple messages… but I think I found a solution. As long as ftp uploads are enabled on the server, and as long as we have a list of files in the directory - which we can just use a dos dir output for - they don’t mind that - there’s no reason why a loop of ftp_put wouldnt work right?

I’ve never used ftp functions through php before so didn’t think of it sooner.

Its quite possible. I guess i have never ftp functions either so I guess the best I advice I can offer is T.I.S (Try It and See).

Sponsor our Newsletter | Privacy Policy | Terms of Service