Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  157] [ 1]  / answers: 1 / hits: 16198  / 12 Years ago, mon, october 22, 2012, 12:00:00

I have a element (that allows multiple file uploads). I would like to use javascript/jquery to get a list of the files that have been selected for upload. Is this possible?



The element looks like



<input type=file name=files[] multiple/>


I am receiving the files with a Play Framework (Java) controller - however that's not really useful for the question.


More From » jquery

 Answers
18

You can get the list from the input element's files property. I think this link can help you. Javascript get number of files and their filenames from file input element with multiple attribute?



Example:



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

[#82434] Saturday, October 20, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marissatinao

Total Points: 447
Total Questions: 90
Total Answers: 93

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;