admin管理员组文章数量:1025207
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).
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).
Share Improve this question asked Dec 7, 2013 at 7:40 ParanoidParanoid 1,9235 gold badges16 silver badges17 bronze badges2 Answers
Reset to default 11Try this code:
var numFiles = $("input:file")[0].files.length;
you may try this too
document.forms["form_name"]["multi_files_input_name[]"].files.length
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).
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).
Share Improve this question asked Dec 7, 2013 at 7:40 ParanoidParanoid 1,9235 gold badges16 silver badges17 bronze badges2 Answers
Reset to default 11Try this code:
var numFiles = $("input:file")[0].files.length;
you may try this too
document.forms["form_name"]["multi_files_input_name[]"].files.length
本文标签: jQueryJavascriptcount how many files were attached to a file upload inputStack Overflow
版权声明:本文标题:jquery - Javascript, count how many files were attached to a file upload input - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1739496074a1653386.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论