Search code examples
htmlformsmultifile-uploader

HTML Input Multiple Tag


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.


Solution

  • 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.