File Upload Fields

If you need to collect uploaded file data then you can use ASP.NET MVC's HttpPostedFileBase type for your model property, e.g.:

public HttpPostedFileBase FileUpload { get; set; }

In order for file uploads to work you will need to set the encoding type on the form to multipart/form-data (as opposed to the default), e.g.:

@using (var f = Html.BeginChameleonForm(encType: EncType.Multipart)) {
    @* ... *@
}

To then use the file upload in your controller action you use the standard approaches. If you want the field to be Required you can annotate with [Required] as normal and check for the property value being null to see if something was submitted by the user.

Default HTML

When using the Default Field Generator then the default HTML of the Field Element will be:

<input %validationAttrs% %htmlAttributes% id="%propertyName%" name="%propertyName%" type="file" value="%value%" />