I am working with WFFM File upload and was asked to restrict File Size and File types. So I created a custom field that inherits the OOTB Upload File of WFFM in order to accommodate the restrictions.

I have tried the ideas in below links..



However, both references seem not working in my machine. I have tried debugging it but not debugging on point. I am not sure if the references stated above work in WFFM 8.1 160523 as it requires an MVC Field.

File Size Validator

File Upload

Please advice me on this.


On https://ggullentops.blogspot.be/2016/05/sitecore-wffm-mvc-fileuploadfield.html I have a solution for a custom field that can check filesize and type.

Without copying the whole code, it comes down to creating a validation attribute(s) that inherit from DynamicValidationBase and override ValidateFieldValue.

Next you create the custom field: inherit from the base FileUploadField in Sitecore.Forms.Mvc.ViewModels.Fields and override the "Value" property, just to add the custom created attributes.

Register the field in Sitecore (Assembly, class and mvc type) and you're good to go. Start using the field in a mvc form, but do not forget to fill in the necessary parameters as required by the validator(s).

  • Hi, I've seen this code before and implemented it. And now is working! Last time I tried it, I did the parameters in the validation. Thanks.
    – ZQuiray
    Oct 26 '17 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.