7

even though i select multiple files using below html.

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

I only get value of first file selected. i am using a simple:

var filelist = $("#multiplefiles").val() || []; $.each(filelist, function(i, myfile) { console.log('found file '+i+' ='+myfile); }); 

please advise how do i get list of all files...

for example selected string in the input field is: C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg, C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg, C:\Users\Public\Pictures\Sample Pictures\upload-2.txt

and from above logic i only get: following in log:

found file 0 =Hydrangeas.jpg 

ty. Rajeev

0

1 Answer 1

10

This should do the trick:

var filelist = document.getElementById("multiplefiles").files || []; for (var i = 0; i < filelist.length; i++) { console.log('found file ' + i + ' = ' + filelist[i].name); } 

A working jsFiddle is here.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much. I also wanted to know about file sizes and by your help - now i know i can use the .size option to get file size. thz again!!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.