Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do the major browsers not support HTMLs ACCEPT attribute for input type="file"?

Does anyone know how to use the accept attribute in input tags? I can see it documented, but w3schools indicates that it is not supported by any of the major browsers. Testing also confirms this.

I know that validation should be done server-side, and am doing that now. But it'd be nice to have it restrict the types of files in the file upload dialog for usability.

Edit: I am fully aware of the security implications of client-side only validation. I do not intend to remove server-side validation and am looking for a way to improve usability.

like image 245
Ricky Hewitt Avatar asked Nov 16 '09 18:11

Ricky Hewitt


2 Answers

The reason why browsers don't actually implement the ACCEPT attribute is that MIME type validation is a science and not just as easy as reading a file extension. Even server-side MIME type verification can be difficult as noted by MediaWiki:

http://www.mediawiki.org/wiki/Manual:Mime_type_detection

Notice they attempt to verify the MIME type even server-side.

like image 200
Keith Adler Avatar answered Sep 29 '22 00:09

Keith Adler


This attribute is supported by every major browser. Useful links are-- caniuse.com

w3 schools browser support for accept attriute

Thought it would be helpful for someone who wants to know about the browser support of HTML accept attribute.

like image 34
neophyte Avatar answered Sep 29 '22 00:09

neophyte