I want wh...">

Javascript, count how many files were attached to file input

I have this file:

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

I want when someone uploads a file / files to it, I want to warn them how many files have been downloaded (in general). For example, if I upload 3 files, it will warn "3 files have been uploaded." And if I add 2 more files, it will warn you “5 files have been uploaded” (adding 2 files uploaded earlier).

+4
source share
2 answers

Try this code:

var numFiles = $("input:file")[0].files.length;
+7
source

you can try it too

document.forms["form_name"]["multi_files_input_name[]"].files.length
+3
source

All Articles