如何使用Jquery和Jquery表单验证插件检查上传文件的大小?
问题描述:
我想在客户端上实现Jquery验证.当用户要上传文件时,Jquery将检查文件的大小,如果超过最大大小,则用户将无法上传文件.如何使用Jquery或Jquery验证插件来做到这一点?
I want to implement the Jquery validation on the client. When a user is going to upload a file, the Jquery will check the size of the file and if it exceeds the max size, a user can not upload the file. How to do it using Jquery or Jquery validation plugin?
答
您无法使用JQuery做到这一点.问题是javascript无法访问文件系统.
You can't do it with JQuery. The problem is that javascript can not access the file system.
以下是您可以阅读的有关该主题的内容-使用jQuery,限制文件上传前的大小
Here is something you can read about the subject - Using jQuery, Restricting File Size Before Uploading