5

I have this file input:

<input type="file" name="photo[]" multiple="yes">

What I want is, when someone uploads a file/files to it, I want to alert them how many files were uploaded (altogether). Like if I upload 3 files, it will alert "3 files were uploaded". And if I add 2 more files it will alert "5 files were uploaded" (adding the 2 files uploaded before).

2 Answers 2

11

Try this code:

var numFiles = $("input:file")[0].files.length;
Sign up to request clarification or add additional context in comments.

Comments

4

you may try this too

document.forms["form_name"]["multi_files_input_name[]"].files.length

1 Comment

its more accurate than previous

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.