2

Is it possible to completely remove the All Files dropdown option when uploading a file through MVC 5 HTML

@TempData["fileType"] accepts (.xml,.txt,.xml) it works but I want to completely remove All Files

 <input type="file" name="file" accept="@TempData["fileType"]"  />

Thanks in advance.

Mohamed Said
  • 524
  • 7
  • 27
  • 1
    That is a function of the OS/browser and you have no control over it. Use a validation attribute so that you get client and server side validation - refer [this answer](http://stackoverflow.com/questions/40199870/how-to-validate-file-type-of-httppostedfilebase-attribute-in-asp-net-mvc-4/40200034#40200034) for an example –  Mar 19 '17 at 21:52

1 Answers1

5

you cannot remove All Files and it has nothing to do with MVC because <input type="file" name="file" /> is an html tag but you can validate the upload file either by using javascript for client side validation or you can use c# for server side validation.

For javascript validation File Type validation with javascript and for server side check File Type Validation MVC 5 . Server side validation is always preferred because javascript can be disabled from browser.

Community
  • 1
  • 1
Usman
  • 4,615
  • 2
  • 17
  • 33