问题
On a page, a fineUploader dropzone is created with some initial validation settings. Before the user hits the Upload button, a few validation settings may change. How to make fineUploader to replace the initial validation rules with the new ones?
I have an application that allows you to create ads of different sizes and i want to use the qq.ImageValidation to validate the image ad dimensions.
回答1:
How to make fineUploader to replace the initial validation rules with the new ones?
You cannot. But you can call a function within the submit event which can dynamically validate files, and set some "base" validators in the validation option.
validation: {
// set default options such as making sure all uploads are images
// or within a certain size.
},
onSubmit: function (id, name) {
var file = this.getFile(id),
validated = validate(file);
if (validated) return true;
else return false;
}
If this function returns false, then the item will not be marked as validated and not be uploaded. If this function returns true, then the validators you set in the options will be ran over the file(s) afterwards.
来源:https://stackoverflow.com/questions/20595950/fineuploader-add-change-validation-rules-on-onvalidate-onvalidatebatch-callback