简体   繁体   中英

How to display multiple file using jquery.MultiFile.js

I'm using jquery.MultiFile.js for uploading file, currently, it's work for 1 select file only, meaning than when I want to upload more than 1 file I need to click select button, choose file 1, then click select button again and choose file 2. I plan to change it with multiple select, meaning that I just need to click select one time, and I can choose both files (file 1 and file 2). So I did add multiple at my input, something like this..

<input type="file" name="picture[]" id="picture" multiple>

And I can choose more than 1 file at the same time, even when I submit my form, all selected file is save into the server, my problem is just, when I select more than 1 file, only 1st file name will display (before submitting my form), I want that all the files names will display before submitting, does anyone have do this before?please share and advice.

Thanks

I believe .files is the attribute you are looking for.

function test() {
    var alist = document.getElementById("picture").files;
    for(var i = 0; i < alist.length; i++) {
       console.log(alist[i].name);
    } 
}

http://jsfiddle.net/Zwkk4/1/

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