0

I was trying to get names of all the files being browsed through file input.

For a single file I know this :

var validfile=document.forms["filesharing"]["file"].value;

But problem is what if i have multiple files browsed ?

HTML :

<form method=post action="stegnographyonshares" enctype="multipart/form-data" onsubmit="return formvalidations()" name="filesharing"> 
    <input type="file" name="file" value="file" id="file" multiple="multiple"/> 
</form>
1
  • Please show the HTML of the form. Commented Jun 7, 2014 at 18:21

1 Answer 1

2

You can access using the files property of file upload control.

var lstFiles = document.forms["filesharing"]["file"].files;

for(var i=0; i < lstFiles.length; i++) {
    var f = lstFiles[i];

    alert(f.name);
}
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry its wrong,Its returning [ObjectData] when i alert f in this loop
@user3704229 What you exactly want to do?
I want name of all files browsed in an array.

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.