Answer the question
In order to leave comments, you need to log in
How to check the number of elements in files[] array using jQuery?
Hello,
<input id="files_0" type="file" name="files[]"></input>
<input id="files_1" type="file" name="files[]"></input>
Answer the question
In order to leave comments, you need to log in
check how many non-empty input elements there are in the DOM with that name
var count = $("input[name='files[]']").filter(function(el){ return $(this).val() }).length;
As far as I know, you can get a list of files with one command only if you use this construction to upload files
but this attribute is supported by far on all browsers .
In your case, you probably have to do a direct enumeration something like this
$('input:file').each(function() {
console.log($(this).val())
} )
; Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question