shinve — 2012-02-19T19:23:11-05:00 — #1
I use the following code to try to get a browser make the OS only display certain file types when a user browses to upload a file.
<input type="file" name="upload" id="upload" accept="image/jpeg, image/png">
But I tried this in Firefox 9 but it doesn't work. It also doesn't work in IE, but it's not supported there yet. Is my syntax wrong? Or does Firefox 9 just not support this?
w3schools says it should work in firefox and others (http://www.w3schools.com/TAGS/att_input_accept.asp)
ralphm — 2012-02-19T20:04:23-05:00 — #2
Yeah, this seems a pretty buggy/flaky attribute right now. You certainly can't rely on anything in HTML5 yeat, as it's still in production and browsers haven't truly embraced it yet. Better to leave it to PHP or similar to do this.
logic_earth — 2012-02-19T20:07:16-05:00 — #3
shinve — 2012-02-19T22:26:21-05:00 — #4
Thanks both of you.
Also, that wufoo site is very cool. Thanks for linking it.
ralphm — 2012-02-19T22:34:31-05:00 — #5
Yes, Chris Coyier is involved in WooFoo. Seems a good service.
Have you tried just using
accept="image/*"? That seems to work well to me.
system — 2012-02-19T22:45:37-05:00 — #6
Welcome to another reason real world use of HTML 5 is a decade off -- even the useful **** doesn't work right.
Fun to play with though... just don't use it on production work if you actually care about people using the site.
shinve — 2012-02-20T01:33:28-05:00 — #7
I've haven't tried image/*. I will try that. When you said "Better to leave it to PHP or similar to do this. " what did you have in mind? I didn't know php was capable of controlling the file upload dialog. I already use php to verify the file on the backend, but I was hoping this front end would make it just a little easier for the user to find a file.
ralphm — 2012-02-20T01:46:00-05:00 — #8