Restrict file types in BlueImp JQuery File Upload

旧城冷巷雨未停 提交于 2019-12-11 04:55:38

问题


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
});

回答1:


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
    });



来源:https://stackoverflow.com/questions/18792129/restrict-file-types-in-blueimp-jquery-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!