Is there any way to add file-type validation to the attribute. My error displays no matter the file type.
public class XmlFile
{
[Required,
DataType(DataType.Upload),
FileExtensions(ErrorMessage = "Please specify a valid .xml file", Extensions = ".xml")]
public HttpPostedFileBase UploadedFile { get; set; }
}
My view:
@using (Html.BeginForm("Index", "Fatca", FormMethod.Post, new {enctype = "multipart/form-data"}))
{
<legend class="form-legend">Upload</legend>
<input type="file" name="UploadedFile"/>
<input type="submit" value="Upload" />
}