Determining File Size Before Upload
Want to know if you can find out the size of a file before uploading it? If using AJAX/PHP and in the change event of the input file, is there any way?
Answer
For the following HTML:
<code class="html"><input type="file" id="myFile" /></code>
Try this:
<code class="javascript">// 绑定到输入字段的 onchange 事件 $('#myFile').bind('change', function() { // this.files[0].size 获取文件的大小。 alert(this.files[0].size); });</code>
See the following thread:
How to check file input size with jQuery?
The above is the detailed content of Here is the article title: Can You Determine File Size Before Uploading with AJAX/PHP?. For more information, please follow other related articles on the PHP Chinese website!