限制BlueImp JQuery文件上传中的文件类型 [英] Restrict file types in BlueImp JQuery File Upload

查看:161
本文介绍了限制BlueImp JQuery文件上传中的文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,我们可以在JQuery File Upload中限制文件类型.在文档中,我们有以下代码,但这仅适用于允许的文件类型.我想要限制文件类型的东西.我想允许所有文件类型,但限制.exe和.js文件.请让我知道是否有任何解决方法.

Is there anyway we can restrict the file types in JQuery File Upload. From the documentation we have below code, but that is only for allowed file types. I want something for restricting file types.I want to allow all the file types but restrict .exe and .js files. Please let me know if there is any workaround for this.

$('#file_upload').fileUploadUIX({
    maxFileSize: 5000000, // Maximum File Size in Bytes - 5 MB
    minFileSize: 100000, // Minimum File Size in Bytes - 100 KB
    acceptFileTypes: /(zip)|(rar)$/i  // Allowed File Types
});

推荐答案

您可能需要多修改一些代码,但是通过将正则表达式更改为以下内容,我能够获得所需的代码:

You may need to alter the code a little more but I was able to get what you wanted by altering the regex to the following:

 $('#file_upload').fileUploadUIX({
        maxFileSize: 5000000, // Maximum File Size in Bytes - 5 MB
        minFileSize: 100000, // Minimum File Size in Bytes - 100 KB
        acceptFileTypes: /(\.|\/)(?!exe|js)$/i  // Allowed File Types
    });

这篇关于限制BlueImp JQuery文件上传中的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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