admin管理员组文章数量:1398794
I have a multiple file input like this:
<input multiple="multiple" type="file" name="file">
When I click it, I get the option to select some files. When I select some files click on "open", I need to display the number of files I selected (let's say in an alert box). I suppose there should be a javascript event to handle this situation, but I can't find it. How could I acplish this?
I have tried searching around stackoverflow but haven't found a solution, although this question doesn't seem overly specific.
I have a multiple file input like this:
<input multiple="multiple" type="file" name="file">
When I click it, I get the option to select some files. When I select some files click on "open", I need to display the number of files I selected (let's say in an alert box). I suppose there should be a javascript event to handle this situation, but I can't find it. How could I acplish this?
I have tried searching around stackoverflow but haven't found a solution, although this question doesn't seem overly specific.
Share Improve this question asked Aug 12, 2014 at 12:39 icarusicarus 1661 gold badge6 silver badges14 bronze badges 3- 1 possible duplicate of HTML5: How to count the length of the files from the multiple-input field – MrUpsidown Commented Aug 12, 2014 at 12:51
- 1 How to count selected file Demo – Shubh Commented Aug 12, 2014 at 12:54
- 1 @MrUpsidown: thank you, I haven't stumbled across that question and I searched a great deal for this issue.. I'll pay more attention next time. – icarus Commented Aug 12, 2014 at 13:00
2 Answers
Reset to default 3try this:-
$("input[type='file']").on("change", function(){
var numFiles = $(this).get(0).files.length
alert(numFiles);
});
Demo
$("input[type='file']").eq(0).files.length;
本文标签: javascripthtml 39inputmultiple39 count number of selected filesStack Overflow
版权声明:本文标题:javascript - html 'input = multiple' count number of selected files - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744734394a2622236.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论