How to select multiple files with <input type="file">?
How to select multiple files with <input type="file">
?
Solution 1:
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.
Solution 2:
There is also HTML5 <input type="file" multiple name="files[]" />
(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.
Solution 3:
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!