<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).But going a bit bigger picture, the problem is that we still use file extensions to denote file type.
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.
That’s quite impressive actually and much more than I would expect from a browser’s <input type=“file”> control.
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.
The server is saying it can't read the other file type, so the alternative is to fail.
Convert the image to a format the site accepts (jpg)?
[ ] Don't show this message again
[OK] [Cancel]Also I'm not sure if you can generalize from your one relative to 99% of users.
Mime types can be spoofed and if you read the data blob's mime from its' type, then just an extension rename will fool it. But if you look at the magic numbers you're saving your server's resources and the uploader's time as it doesn't even try to move the file if the mime is not acceptable. No reason not to do it on the client-side first.
I mean ... isn't that kind of a classic trick when handing in homework you didn't make? Just rename some file to .doc and claim it got corrupted?
How is it possible that students that are being considered for "advanced placement" are not familiar with file formats?
how horrible and backward your education system must be? This belongs to basic literacy in the modern world.
Note we're not speaking about old people who were exposed to files for the first time while they had to balance a family life and other responsibilities.
We're speaking about people that were forced to spend more than half of their lives learning !!!
Even as a software engineer, I haven't used a desktop or windows in 5 years. I haven't used TheGimp (or any other non web/app image manipulation software) in 3 years.
from my experience converting ppt/word to pdf is a common enough use case that I would've assumed the majority of non-tech people run into it.
Latex is also a common case where you run into file extensions.
note I'm not expecting them to understand the difference between extensions, just what they mean and how to google how to convert between them.
What they're doing is the same as 99% of other sites that expect images. But it's probably fair to expect it to be even more streamlined (i.e: clear conversion instructions) given the circumstances of a time-limited exam.