Reputation: 35
This code isn't working, I guess it's because .join('') doesn't work in jquery but I can't find any solution that seems legit. Thanks for your help. If needed I can show what I have in my html file:
<form id="img_search">
<input type="file" id="files" name="files[]" multiple/>
<output id="list"></output>
</form>
js code:
$( "#files" ).bind('change', function() {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
f.size, ' bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
$("#list").html('<ul>' + output.join('') + '</ul>');
});
Upvotes: 0
Views: 715
Reputation: 9356
You forgot to pass the event to the callback - jsFiddle
$( "#files" ).bind('change', function(event) {
var files = event.target.files;
});
Upvotes: 3