angular 1.x 文件上传 怎么判断文件大小

需求是选择文件后,判断文件大小,若超过100M,给出相应报错信息

慕田峪9158850
浏览 602回答 1
1回答

临摹微笑

监听上传文件input的onchange事件,&nbsp;$('#fileUpload').on('change', function (evt) {&nbsp; &nbsp; &nbsp; &nbsp; var files = evt.currentTarget.files;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (var i = 0; i < files.length; i++) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var fileSize = files[i].size;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//some your code&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript