Reputation: 49
<input type="file" name="prod_detail_image[]" id="prod_detail_image"
value="" multiple="multiple" onblur="validatebutton();" />
I can choose multiple files in the file input. In onblur event I need to get the file values which was selected. I am getting only one value. I need to get the array values of images.
Upvotes: 0
Views: 240
Reputation: 1
var inp = document.getElementById('prod_detail_image');
for (var i = 0; i < inp.files.length; i++) {
var name = inp.files[i].name;
alert("here is a file name: " + name);
}
check this.It will work.
Upvotes: 0
Reputation: 4372
There are many other similar questions on SO. Here is a simple way to get all the filenames
var inp = document.getElementById('prod_detail_image');
for (var i = 0; i < inp.files.length; ++i) {
var name = inp.files.item(i).name;
alert("here is a file name: " + name);
}
However this will only work in browsers that support HTML5
Upvotes: 1