简体   繁体   中英

How to get multiple files in Fileupload

<input type="file" id="fup" multiple/>
alert($("#fup").val());

Here I am getting only single file in the alert() even though I am selecting multiple files. How can I get multiple files in the alert() with complete url path ?

Use the files collection of the underlying DOMElement:

var files = $('#fup')[0].files;
for (var i = 0; i < files.length; i++) {
    console.log(files[i].name);
}

Working example

Also note that you shouldn't use alert() for debugging. It coerces the datatypes and is generally not a good idea. The console is always preferable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM