Home File input 'accept' attribute - is it useful?
Reply: 0

File input 'accept' attribute - is it useful?

user8093 Published in September 19, 2018, 6:43 pm

Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the <input type="file" ...> tag.

Is this attribute useful as a way of limiting file uploads to images, etc? What is the best way to use it?

Alternatively, is there a way to limit file types, preferably in the file dialog, for an html file input tag?

share|improve this question
  • 1
    Regarding the Li Huan's reply, the right link to w3school is: w3schools.com/TAGS/att_input_accept.asp – PixEye Dec 21 '11 at 16:02
  • 1
    I've just tried using 'accept=application/x-gzip' and it worked with 'Chrome 19.0.1084.52', but does nothing in 'FF 13.0' and 'IE 8.0.6001'. – Jeach Jun 14 '12 at 19:26
  • Check out jsfiddle.net/jhfrench/cukjxnp6/embedded/result for a way to enhance input type="file" to validate that only accepted file types can be chosen. – Jeromy French Dec 23 '15 at 23:07

8 Answers 8

active oldest votes
up vote 396 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.398632 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO