I am sure I am missing something here, I found this question to validate a file, here is the sample code
public class UpdateSomethingViewModel
{
[DisplayName("evidence")]
[Required(ErrorMessage="You must provide evidence")]
[RegularExpression(@"^abc123.jpg$", ErrorMessage="Stuff and nonsense")]
public HttpPostedFileBase Evidence { get; set; }
}
but I don't see any @Html.FileFor(model => model.Evidence)
Any ideas?
Update
I found a simple solution passing attribute type in html attribute collection.
@Html.TextBoxFor(model => model.Evidence, new { type = "file" })
@Html.ValidationMessageFor(model => model.Evidence)