I have a controller like this:
public ActionResult Upload (int id, HttpPostedFileBase uploadFile)
{
....
}
How can I make sure that uploadFile
Or you can check it on client side thru html attribute 'accept' to filter the file asap:
@Html.TextBoxFor(x => x.HomeDeviceImage, new { @type = "file", @accept = "image/x-png, image/gif, image/jpeg" })
this will only show filetypes defined in your accept attribute as default. Beware, user can still change filetye to "All files", with this in mind, better check this:
Solved concern , a javascript snippet to check extension, and then do some editing to disable button like:
$('input:submit').attr('disabled', true);
until file extension is correct. nevertheless have it checked on server side. :)