Use two <input type=file> elements instead, without the multiple attribute. If the requirement is really just "have two different single inputs", then this is actually the best answer @Diego.
You could add a new <input type="file"> whenever you finished uploading the previous files and hide the previous input. This way you keep adding a new input every time you want to add more files and prevent the previous input from being overwritten.
When you set the Multiple file selection, the user can select more than one file from the File Upload dialog box by holding the Ctrl key or they can click on a file, then hold Shift down, and click on another file so all the files between them are selected(Apple computers support this using the Command key).
New answer:
In HTML5 you can add the multiple
attribute to select more than 1 file.
<input type="file" name="filefield" multiple="multiple">
Old answer:
You can only select 1 file per
<input type="file" />
. If you want to send multiple files you will have to use multiple input tags or use Flash or Silverlight.
There is also HTML5 <input type="file[]" multiple />
(specification).
Browser support is quite good on desktop (just not supported by IE 9 and prior), less good on mobile, I guess because it's harder to implement correctly depending on the platform and version.
The whole thing should look like:
<form enctype='multipart/form-data' method='POST' action='submitFormTo.php'>
<input type='file' name='files[]' multiple />
<button type='submit'>Submit</button>
</form>
Make sure you have the enctype='multipart/form-data'
attribute in your <form>
tag, or you can't read the files on the server side after submission!
This jQuery plugin (jQuery File Upload Demo) does it without flash, in the form it's using:
<input type='file' name='files[]' multiple />
You can do it now with HTML5
In essence you use the multiple attribute on the file input.
<input type='file' multiple>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With