Reputation: 47
How to get a value from <input type="file" name="attach_1" multiple>
using jQuery?
I did try $('input').val()
, but when you use 2+ files it sends back just first one.
Upvotes: 0
Views: 689
Reputation: 15555
$('#input').change(function(e) {
var file = $('#input')[0].files;
for (var i = 0; i < file.length; i++) {
console.log("file_" + i, file[i].name);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input type="file" id="input" name="input" multiple="">
Try this way
Upvotes: 1