I have a simple HTML form that I am building. I want to be able to added multiple files to submit with the form to upload. Everything I am reading online about HTML5 says that I am able to do this with the HTML5 Input Multiple tag. When I try this in any browser I get the standard Input with a type of file. When I inspect the DOM i see that it has only a single file in it's Files[0] attribute. Here is my form. Please let me know what I am doing wrong.

Here is my HTML for the the form for uploading files:

<form method="post" action=upload.php" enctype="multipart/form-data">
       <input type="file" id="basicUploadFile" multiple >
</form>

Also. I have tried this in Chrome, Firefox, IE 11. Even going to the W3school.com demo doesn't seem to work in any of them for multiple files.

有帮助吗?

解决方案

files[0] will show you the first file selected. files gives you a collection of the selected files, files.length gives you the number of files selected. So once you select more than one file if you console.log(fileinput.files) you'll see multiple files logged.

其他提示

<form method="post" action="upload.php" enctype="multipart/form-data">
 <input type="file" id="UploadedFiles" name="UploadedFiles[]" multiple>
 <input type="submit" value="SendFile">
</form>

in upload.php analize structure of array $_FILES ;)

good like!

Is that a typo? There is a " missing before the upload.php

your form tag looks correct

http://en.wikipedia.org/wiki/File_select#Multiple_file_selection

[edit] If you are referring to the W3schools site, this works for me on Chrome and IE http://www.w3schools.com/tags/att_input_multiple.asp

TryIt site:

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_multiple

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top