jquery 获取上传文件大小
程序员文章站
2022-10-25 17:16:12
1. ......
1.
<html> <head> </head> <body> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script><br/> <input id="fupload" multiple type="file"/> <ul id="ullist"></ul> <input id="btnshow" type="button" value="show"/><br/> <script> $(document).ready(function(){ $("#btnshow").on('click', function () { $("#ullist").empty(); var fp = $("#fupload"); var lg = fp[0] .files.length; var items = fp[0].files; var fragment = ""; if (lg > 0) { for (var i = 0; i < lg; i++) { var filename = items[i].name; //获得文件名 var filesize = items[i].size; //获得文件大小 var filetype = items[i].type; //获得文件类型 //在ul标签显示文件信息 fragment += "<li>" + filename + " " + filesize + " bytes. type :" + filetype + "</li>"; } $("#ullist").append(fragment); } }); }); </script> </body> </html>
上一篇: 山药是根吗,这里有答案哦