Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create filter on html file chooser dialog

Tags:

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!

like image 379
amitdar Avatar asked Dec 12 '12 08:12

amitdar


2 Answers

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"> 
like image 109
deceze Avatar answered Oct 17 '22 10:10

deceze


For others arriving here, these are some very handy predefined sets:

<input type="file" accept="image/*"/> <input type="file" accept="video/*"/> <input type="file" accept="audio/*"/> 
like image 27
Richard Dunn Avatar answered Oct 17 '22 09:10

Richard Dunn