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.


2 Answers 2


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, 2017 at 14:18

This is for the latest version of Sitecore. If you are finding a way to create a custom validation rule in Sitecore to handle this on a specific image field on a template then you can consider my brief answer in a dedicated blog here. The Ask or the Task to achieve is listed below - the solution for which I have provided in the blog itself.


The requirement was to limit image size on a image field in any template and also to restrict the type of image.

For example: The image should be less then 1 MB & should be either png or jpg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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