问题
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