3 ms·
No, what 99% of sites are doing is <input type="file" accept="image/png, image/jpg, image/jpeg" /> If you do that, Safari will convert the HEIC image to a
by LeifCarrotson 6y ago
No, what 99% of sites are doing is
<input type="file" accept="image/png, image/jpg, image/jpeg" />
If you do that, Safari will convert the HEIC image to a JPEG automatically when you try to upload it.
What they did instead was to poorly reinvent the accept header in Javascript as follows:
<input
type="file"
...
onChange={async e => {
const split = file.name.split('.')
const fileType = split[split.length-1].toLowerCase()
const isAllowedExtension = extensions.includes(`.${fileType}`)
}}
/>
(per https://news.ycombinator.com/item?id=23261598 https://news.ycombinator.com/item?id=23261598).
- zaroth 6y ago> If you do that, Safari will convert the HEIC image to a JPEG automatically when you try to upload it. That’s quite impressive actually and much more than I would expect from a browser’s <input type=“file”> control.
- smt88 6y agoIt's also not what a browser should do. JPEG conversions will vary in quality and size. On some sites (e.g. a CMS), quality can be sacrified to stay within file size limits. On other sites, like photo printing services, quality is much more important. These may be unusual cases, but silent browser assumptions are still an overstep.
- zaroth 6y agoThere's nothing stopping the user from doing a conversion themselves if they want to (and know how, which is asking a lot). The server is saying it can't read the other file type, so the alternative is to fail.
- Thorrez 6y agoThere's a medium option: have an alert popup saying Convert the image to a format the site accepts (jpg)? [ ] Don't show this message again [OK] [Cancel]
- lightgreen 6y agoAnecdotally, yesterday I accidentally learned that my relative clicks OK in any dialog window within 200ms without even attempt to read the message. So the alert you suggest would slightly help 1% of geeks and will annoy 99% of the users.
- Thorrez 6y agoCompared to the option of not converting, it would help everyone, reducing annoyance. Also I'm not sure if you can generalize from your one relative to 99% of users.
- LordDragonfang 6y agoWhile it may not be 99%, /r/talesfromtechsupport on reddit has enough instances of this to suggest it is extremely common user behavior.
- askvictor 6y agoThat might be part of the problem, though other comments also point out that students were copying file to a computer, then changing file extension, then uploading. Possibly this was as a result of the iOS browser rejecting the file in the first place due to the shoddy input filtering mentioned. But going a bit bigger picture, the problem is that we still use file extensions to denote file type.
- Wowfunhappy 6y agoThis keeps getting brought up because there was one anecdote in the Verge story about a student who renamed the file on their computer. (Which still shouldn't have caused the test to keel over, but it's at least slightly more understandable.) However, there were many other reports of students going the more "normal" route of just uploading through their iPhones, which caused the website to outright hang.
- technion 6y agoJust to give credit where it's due here, I don't think I've ever seen a client side form check upload sizes before. I've had many frustrations going through a form upload then refreshing to a page that says "your file was too big".