简体   繁体   English

jQuery文件上传插件(BackLoad):如何限制文件的数量和大小?

[英]JQuery File Upload Plugin (BackLoad): How to limit # and size of files?

I'm using JQuery File Upload plugin with BackLoad for uploading files in MVC4 application. 我使用带有BackLoad的JQuery File Upload插件在MVC4应用程序中上传文件。 The upload works fine. 上载正常。 However, I could not figure out a way to limit the # and size of files. 但是,我想不出一种方法来限制文件的#和大小。 Can we do this in the plugin? 我们可以在插件中执行此操作吗?

Now, user can add as many files (images) as they want and file size can be very large. 现在,用户可以根据需要添加任意数量的文件(图像),文件大小可能非常大。 I only want to allow them upload 1 file and size < 10MB at a time. 我只想允许他们一次上传1个文件,且大小小于10MB。

I tried to change the template-upload to show just one file, but it does not work. 我试图将模板上传更改为仅显示一个文件,但是它不起作用。 It seems when multiple files are selected, the template-upload will be used multiple times. 似乎当选择了多个文件时, 模板上载将被多次使用。 Each time, files only has one file. 每次文件只有一个文件。

I also changed maxFileSize in Backload.Default.config , but it does not work. 我还更改了Backload.Default.config中的maxFileSize ,但是它不起作用。 It seems it is for images that are already uploaded. 似乎是针对已经上传的图像。

Before I used Ajax toolbox in web form, and they can be done easily. 在以Web形式使用Ajax工具箱之前,可以轻松完成它们。 Now, I'm trying this in mvc4 application, any idea of how to achieve these? 现在,我正在mvc4应用程序中尝试此操作,如何实现这些功能的任何想法?

Thanks 谢谢

设置属性maxFileSize:5000000,// 5mb和maxNumberOfFiles:1将在客户端影响它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM