JQuery - get all fileNames inside input='file'

javascript, jquery

Solution

var files = $('#basicUploadFile').prop("files")

`files` will be a FileList object.

var names = $.map(files, function(val) { return val.name; });

Now `names` is an array of strings (file names)

FileAPI reference files property reference

Problem

I have `<input type="file" id="basicUploadFile" multiple="multiple">` and I want to get all file names inside this input. I've seen some example, but it gets only name of first file. ``` $ ('#basicUploadFile').live ('change', function () { alert($ ('#basicUploadFile').val()); }); ``` How can I do this? Thanks.

Original source

Related problems