Create filter on html file chooser dialog

amitdar picture amitdar · Dec 12, 2012 · Viewed 13.1k times · Source

Is there a way to show only .xxx files in the default file chooser dialog. xxx may be not-known file types, such as abc, efg etc.

I'm using html5 so it may have new support for this type of things.

Thanks!

Answer

deceze picture deceze · Dec 12, 2012

The HTML 5 accept attribute on file input elements is for this purpose. E.g.:

<input type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">