Why don't major browsers support ACCEPT HTML attributes for input type = "file"?

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

I know that validation must be done on the server side, and I'm doing it now. But it would be nice if he limited the file types in the file download dialog for ease of use.

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

+5
source share
4 answers

The reason browsers don't actually implement the attribute ACCEPTis because checking the MIME type is science and not as simple as reading the file extension. Even server-side MIME type checking can be difficult, as pointed out by MediaWiki:

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

Note that try to check the MIME type even on the server side.

+3
source

This attribute is supported by each major browser. Useful links: caniuse.com

w3 school browser support for attriute adoption

, , HTML accept.

+3

, HTML4 ( ):

, , , . .

.

. , image/* . text/* .. , iPhone, , , , . . .

, - , -.

+1

Supporting this tag will mean implementing a way for the browser to determine the MIME type of the local resource, and this will entail a sufficient number of heuristics and possible exposure to code injection and / or other vulnerabilities that browsers already have a fair share of.

0
source

All Articles