views:

2334

answers:

3

I have experience doing this with single file uploads using <input type="file">. However, I am having trouble doing uploading more than one at a time.

For example, I'd like to be able to select a series of images, then upload them to the server, all at once.

It would be great to use a single file input control, if possible.

Does anyone know how to accomplish this? Thanks!

A: 

partial answer: pear HTTP_UPLOAD can be usefull http://pear.php.net/manual/en/package.http.http-upload.examples.php

there is a full example for multiple files

dam
You can use the PEAR package but this task is fairly trivial and unless you need the extra features that the package provides (internationalized error messages, validation, etc...) I would recommend using the native PHP functions. But this is only my opinion. :)
MitMaro
I agree with you, that's why I wrote "partial answer". But I also do my best to re-use code and I often work as much as I can with pear (pear coders are much more better than me :-D)
dam
+3  A: 

If you want to select multiple files from the file selector dialog that displays when you select browse then you are mostly out of luck. You will need to use a Java applet or something similar (I think there is one that use a small flash file, I will update if I find it). Currently a single file input only allows the selection of a single file.

If you are talking about using multiple file inputs then there shouldn't be much difference from using one. Post some code and I will try to help further.


Update: There is one method to use a single 'browse' button that uses flash. I have never personally used this but I have read a fair amount about it. I think its your best shot.

http://swfupload.org/

MitMaro
I added the link to the flash based multiple uploader.
MitMaro
I've used swfupload fwiw - it's a bit of a pain on occasions but it's not really that hard to get working.
Meep3D
+1  A: 

If you use multiple input fields you can set name="file[]" (or any other name). That will put them in an array when you upload them ($_FILES['file'] = array ({file_array},{file_array]..))

Torandi