Closed Bug 1367490 Opened 7 years ago Closed 4 years ago

<input type="file" accept="image/jpeg"> doesn't work on Windows

Categories

(Core :: DOM: Core & HTML, defect, P3)

Unspecified
Windows
defect

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: ted, Assigned: Gijs)

References

(Depends on 1 open bug, )

Details

See the URL for a testcase. It has `<input type="file" accept=".jpeg,image/jpeg">`, but the file picker dialog only allows selecting `*.jpeg`. In Chrome this lets me select `*.jpg` files as well. Google Photos has an "Upload" button whose HTML looks like: <input multiple="" style="display: none" jsname="G1bupd" accept=".3fr,.3gp,.arw,.cr2,.crw,.dc2,.dcr,.dng,.erf,.jpeg,.k25,.kdc,.mdc,.mef,.mos,.mov,.mrw,.mts,.nef,.nrw,.orf,.pef,.qtk,.raf,.raw,.rdc,.rw2,.sr2,.srf,.x3f,image/bmp,image/gif,image/jpeg,image/png,image/tiff,image/webp,video/mp4,video/x-m4v,video/*" type="file"> They list .jpeg but not .jpg, and image/jpeg. In Chrome this lets me select all image files. In Firefox it will only let me select the file extensions in the list, so not .jpg. I finally realized that I could scroll up in the extensions list to "All Files (*.*)", but it was not obvious given how many entries we display in the list. I filed a webcompat issue on this as well: https://github.com/webcompat/web-bugs/issues/6956
Ted, which version were you using? Bug 1364550 was landed days ago, and I cannot reproduce your problem on the latest nightly. Mind trying again?
Flags: needinfo?(ted)
I can still reproduce this with the testcase in the URL on Windows 10, Nightly 20170524030204.
Flags: needinfo?(ted)
Aha, right, bug 1364550 aimed at macOS. Bug 1364550 comment 9 did say we need one bug for windows. Thanks :)
OS: Unspecified → Windows
See Also: → 1364550
Summary: <input type="file" accept="image/jpeg"> doesn't work → <input type="file" accept="image/jpeg"> doesn't work on Windows
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #3) > Aha, right, bug 1364550 aimed at macOS. Bug 1364550 comment 9 did say we > need one bug for windows. Thanks :) Bug 1366645 was filed to consider having a predefined extenstion list for a mime type.
Depends on: 136645
Priority: -- → P3
I guess you meant bug 1366645 :)
Depends on: 1366645
No longer depends on: 136645
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0 20170524030204 (In reply to (PTO June 23rd-30th) Ted Mielczarek [:ted.mielczarek] from comment #0) > See the URL for a testcase. It has `<input type="file" > accept=".jpeg,image/jpeg">`, but the file picker dialog only allows > selecting `*.jpeg`. (In reply to (PTO June 23rd-30th) Ted Mielczarek [:ted.mielczarek] from comment #2) > I can still reproduce this with the testcase in the URL on Windows 10, > Nightly 20170524030204. I couldn't reproduce this in the latest beta and thought it must've been fixed down the road. But no, it works for me with the build from comment 2 as well.
the bug is still reproducable on win10. <input type="file" accept="image/jpeg, image/png"> you won't be able to see any .jpg files in this case ver 61.0.2 (64-bit)
The live example at MDN [1] (accept="image/png, image/jpeg") has produced two different filters for me (Windows 10 Pro) within a few days: - Firefox/60.0.2 x64: "*.png;*.png;*.jfif" - Firefox/60.0.3 x64: "*.png;*.png;*.jpeg" I've checked other PCs running Windows 10 and I get entirely different extension lists, none of them fully correct. [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
(In reply to Álvaro González from comment #8) > The live example at MDN [1] (accept="image/png, image/jpeg") has produced > two different filters for me (Windows 10 Pro) within a few days: > > - Firefox/60.0.2 x64: "*.png;*.png;*.jfif" > - Firefox/60.0.3 x64: "*.png;*.png;*.jpeg" > > I've checked other PCs running Windows 10 and I get entirely different > extension lists, none of them fully correct. > > > [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file Sorry, I meant latest stable versions (62.0.x).
See Also: → 1508337
See Also: → 1619153
Depends on: 1619203

I think we can consider bug 1619153 (and probably bug 1508337) as a duplicate of this bug.
Those bugs should be fixed by implementing bug 1619203, which I think is the good way to go.

As the person who implemented support for mime type for accept attribute a while ago (bug 565274), I'm fine having a look at this.

The logic to translate mime type to file extensions is done in nsHTMLInputElement.cpp by calling nsExternalHelperAppService::GetFromTypeAndExtension.
We could upload the logic here, but this code is called in other places so we would need to be sure this doesn't introduce any issue.
If that case, we could implement this logic only in nsHTMLInputElement.cpp.

Actually, bug 1366645 should probably be implemented first, and would fix most of the issues mentioned in bug 1619203.

See Also: → 1619203

This got fixed by bug 1366645.

Assignee: nobody → gijskruitbosch+bugs
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78
You need to log in before you can comment on or make changes to this bug.