0

I tried to use the accept of input type="file" with accept to have string as ".doc,.docx,.txt,.rtf" but it still shows .csv.js and .spec.js files

<input type="file"
accept=".doc,.docx,.txt,.rtf"./>

Adding a screenshot , this happens to be only on chrome enter image description here

Geeky
  • 7,420
  • 2
  • 24
  • 50
  • Possible duplicate of [Limit file format when using ?](https://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file) – imvain2 Mar 14 '19 at 22:18
  • no its not ...i did use accept but i still see non filtered files as well, like js and .spec.js and log files – Geeky Mar 14 '19 at 22:19
  • 1
    even when using SO's snippet as a test you see the wrong files? Hmm, that is odd because I tested in FF, Chrome and IE and still only see the appropriate files. – imvain2 Mar 14 '19 at 22:25
  • 1
    It does not show any other files beside `.doc,.docx,.txt,.rtf`. Is it possible for you to add a screenshot if the issue? – node_modules Mar 14 '19 at 22:28
  • 1
    added the screenshot – Geeky Mar 14 '19 at 22:31
  • Ok so this might be a chrome on Mac issue. That link I posted mentions trying mime types instead of extensions – imvain2 Mar 14 '19 at 22:35
  • which browser(s) are you seeing the issue in, and what what operating system and version? – ADyson Mar 14 '19 at 22:36
  • this is on chrome and mac – Geeky Mar 14 '19 at 22:36
  • again, which versions of Chrome and Mac OS? Does it happen on any other browser on the Mac, e.g. Safari or Firefox? – ADyson Mar 14 '19 at 23:15

1 Answers1

0

The problem is that the accept parameter uses the MIME Type, so it may not work .doc Uses MIME Type for different versions:

.doc application/msword .dot application/msword 
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document 
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template 
.docm application/vnd.ms-word.document.macroEnabled.12 
.dotm application/vnd.ms-word.template.macroEnabled.12

If you need other types https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

PetrS
  • 51
  • 1