I want to verify the type of the uploaded file, that's how I do it:
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult GetDataFromFile()
{
var file = Request.Files.Get(0);
...
if (file.ContentType != "text/csv")
{
ModelState.AddModelError("FileInput.File", "The file uploaded is not in the correct format, please upload a csv file");
return View("Index", new CandidateBulkInsertIndexInput());
}
...
}
but I always get application/octet-stream, anybody knows how to check if it is an csv or text MIME type ?