5

Anybody knows why this input accepts .php file extensions?

( At least in the latest version of chrome )

<input type="file" accept=".doc,.pdf,.txt,.rtl">

enter image description here

Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378
  • Please Refer this, it says use file types rather than extensions http://stackoverflow.com/questions/17293861/how-to-make-input-type-file-accept-only-these-types – Sasikumar Sep 15 '16 at 10:34
  • FWIW, a `.php` file basically *is* a `.txt` file for all intends and purposes… Chrome's behaviour isn't even wrong. – deceze Sep 15 '16 at 10:41
  • check type of your file with checkfiletype.com it should be MIME Type: text/plain; – Majid Sep 15 '16 at 10:42
  • @deceze, no, the file extension should be taken into consideration, not the MIME when you set `.any`. `.txt` can be anything. Note that if you do rename an `image/png`to `file.txt`, chrome will still show it as accepted – Kaiido Sep 15 '16 at 10:43
  • @Kaiido Yes, but that's debatable. A .txt file contains pure text. A .php file contains pure text. Po-tay-to, po-tah-to… :) – deceze Sep 15 '16 at 10:44

1 Answers1

4

This is apparently a Mac Os only bug.
I wasn't able to reproduce it from my win10 VM, but it is still there in v.55.0.2861.0 canary.


The problem seems to come from the .txt.
It's like it will accept any text/* files, when this extension is set.

You can star this chromium issue which treats of the same underlying issue (with a different extension).

<input type="file" accept=".txt">
Kaiido
  • 123,334
  • 13
  • 219
  • 285