Reputation: 45
I am using the option "allowedExtensions" without any problem but there is a situation where I have to permit any type of extension but two.
Is there a simple way to do that? I didn't find an option like 'restrictedExtensions' to do that in the code.
Thanks
Upvotes: 0
Views: 1009
Reputation: 2041
From the docs:
The
validate
andvalidateBatch
events are thrown/called before the default Fine Uploader validators (defined in the options) execute.
Also, if your validation event handler returns false
, then Fine Uploader will register that file as invalid and not submit it.
Here's some code you could try in your validate
event handler. It has not been tested yet so YMMV.
var notAllowedExts = ['pptx', 'xlsx', 'docx'];
/* ... */
onValidate: function (fileOrBlobData) {
var valid = true;
var fileName = fileOrBlobData.name || '';
qq.each(notAllowedExts, function(idx, notAllowedExt) {
var extRegex = new RegExp('\\.' + notAllowedExt + "$", 'i');
if (fileName.match(extRegex) != null) {
valid = false;
return false;
}
});
return valid;
}
/* ... */
Upvotes: 1