上传前获取文件大小 [英] Get file size before uploading
本文介绍了上传前获取文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在输入文件的更改事件中使用 AJAX/PHP 上传文件之前,有什么方法可以找出文件大小吗?
Is there any way to find out the file size before uploading the file using AJAX / PHP in change event of input file?
推荐答案
对于下面的 HTML
<input type="file" id="myFile" />
尝试以下操作:
//binds to onchange event of your input field
$('#myFile').bind('change', function() {
//this.files[0].size gets the size of your file.
alert(this.files[0].size);
});
请参阅以下主题:
这篇关于上传前获取文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文