1

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" />
}
ManxJason
  • 928
  • 12
  • 33
  • see http://stackoverflow.com/questions/8536589/asp-net-mvc-3-dataannotations-fileextensionsattribute-not-working and here http://stackoverflow.com/questions/14718425/cant-get-mvc-4-fileextensions-attribute-to-work-on-viewmodel-property – Ric Feb 17 '15 at 12:19

0 Answers0