0
<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.

5
  • where's your code? where's the error? javascript, php, html? Commented Oct 4, 2012 at 5:45
  • I have used the above html code. And I need to get the image array value in javascript. But there I am getting only one image value instead of 3 or 4 values.. Commented Oct 4, 2012 at 5:48
  • first of all remove the value, secondly ignore the spaces in your name, fill it up with underscores..thirdly ignore name and id to be same..and last but not the lease edit your question, give your javascript/php whatever you think it fails and than wait for an answer Commented Oct 4, 2012 at 5:49
  • var files = document.forms['addproduct']["prod_detail_image[]"]; alert(files.length); Commented Oct 4, 2012 at 6:26
  • This is my javascript code for getting the image array value Commented Oct 4, 2012 at 6:27

2 Answers 2

1

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

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

Comments

0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.