FineUploader: Add/change validation rules on onVal

2019-09-16 03:12发布

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条回答
We Are One
2楼-- · 2019-09-16 04:02

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.

查看更多
登录 后发表回答