I am trying to open a file using <input type="file" ...> and display it as text. I want the dialog box that pops up to open the file to show a particular extension of the file like ".txt" or ".jpg" instead of "All Files". how can I do that using javascript alone?
-
I think you can do thhat with accept attribute of input element.Vlas Bashynskyi– Vlas Bashynskyi2014-07-01 14:09:30 +00:00Commented Jul 1, 2014 at 14:09
-
I checked but accept just specifies if you want to use audio, video or image files etc. you cannot specify the extension of the file being selected. Thanks for the help thoughSHuss– SHuss2014-07-01 14:13:45 +00:00Commented Jul 1, 2014 at 14:13
Add a comment
|
1 Answer
You can use the accept attribute in the input:
<input type="file" accept=".txt,.jpg">
For more info, see MDN.