如何使用 jQuery 和 jQuery Validate 插件检查上传文件的大小? [英] How to check the size of an uploaded file using jQuery and jQuery Validate plugin?

查看:18
本文介绍了如何使用 jQuery 和 jQuery Validate 插件检查上传文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端实现 jQuery 验证.当用户要上传文件时,Jquery 会检查文件的大小,如果超过最大大小,用户将无法上传文件.如何使用 jQuery 或 jQuery Validate 插件来做到这一点?

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 Validate 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

这篇关于如何使用 jQuery 和 jQuery Validate 插件检查上传文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆