7

According to MDN accept=[MIME type] is supported in Firefox. However, I tried the following to no avail:

<input type="file" accept="text/html">


It doesn't filter the HTML files: demo.
Is it a bug or am I missing something?

  • How are you testing it? What result did you expect? What result did you get? – Quentin May 11 '14 at 07:58
  • possible duplicate of [How to restrict my input type="file" to accept only png image files not working in Firefox](http://stackoverflow.com/questions/10381999/how-to-restrict-my-input-type-file-to-accept-only-png-image-files-not-working) – Jukka K. Korpela May 11 '14 at 13:46
  • Contrary to what MDN says, Firefox supports only the values `image/*`, `audio/*`, and `video/*` for `accept`. There have apparently been attempts at fixing this, but it is unclear what the exact status is. The answers to the duplicate question suggest JavaScript check as a workaround. – Jukka K. Korpela May 11 '14 at 14:05
  • It kind of works for me. But not really. By default it selects "All files" in the file picker dropdown, but I can manually select "html file". – evilpie May 11 '14 at 16:49
  • @evilpie: ...and when you select "html file" it shows no HTML files! –  May 12 '14 at 01:54
  • 1
    @Jukka K. Korpela: JavaScript validation and the `accept` attribute do different things: the `accept` attribute filters the files you see in the `Open` dialog so you can easily find and work with the desired files among the clutter while you can still select `All Files` and see/select other files. But the JavaScript validation doesn't filter the files you see and just doesn't allow you to upload the unwanted ones. –  May 12 '14 at 02:04

2 Answers2

2

This is a known Firefox bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=826185

Fortunately, it appears there is a patch for the issue that should be reviewed soon.

mattbasta
  • 13,492
  • 9
  • 47
  • 68
1

I think it's a bug or not yet fully implemented.

Dominik Schmidt
  • 537
  • 1
  • 8
  • 22