在输入文件的更改事件中使用 AJAX/PHP 上传文件之前,是否有任何方法可以找出文件大小?
最佳答案
对于下面的 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);
});
请参阅以下主题:
关于javascript - 上传前获取文件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7497404/