0

I have an input that I do not want to accept GIFs for. Is it possible to use the accept attribute to block certain types of files? Thanks for the help!

My current set up looks like this: accept="image/*"

AndrewLeonardi
  • 2,735
  • 7
  • 36
  • 72
  • 1
    You can validate it with simple javascript like in [this](https://stackoverflow.com/a/4237161/863110) answer. Of course, you should validate it in server too.. – Mosh Feu Oct 23 '17 at 15:09

1 Answers1

2

Is it possible to use the accept attribute to block certain types of files?

No. The user can still select any file at local filesystem, even when accepts attribute is set. The value at accepts attribute is only a suggestion to the user. You will need to perform additional checks as to the actual file type at client side before posting data to server and, or perform validation at the server.

See also make ASP.Net file upload secure.

guest271314
  • 1
  • 10
  • 82
  • 156