Files extensions are an old DOS thing that’s still in Windows. Unix-derived stuff never really cared, at least not in the same way.
What actually matters is the MIME type set in the HTTP headers, which is “image/png” for png. Traditionally, the file extension is mapped to a MIME type, because that makes things easy for everyone, but nothing says it has to be that way.
The HTTP headers can be wrong, the only definitive way to determine a file’s content type is to read it. This is why you can stick an image that has a mime type header of application/octet-stream in an img tag and it’ll mostly work. Most binary formats will have some kind of magic number at the start to help determine it.
Meh, you shouldn’t need a sophisticated understanding of file formats and web server configuration to make a website, so some slack is imo a good thing. Maybe not as much as there is, but reading the head of an image file doesn’t seem that big a deal.
The unsophisticated solution is to map the file extension to the MIME type, which is done by default much of the time. If you do anything else, then we need to have a conversation about how.
Literally anything.
Files extensions are an old DOS thing that’s still in Windows. Unix-derived stuff never really cared, at least not in the same way.
What actually matters is the MIME type set in the HTTP headers, which is “image/png” for png. Traditionally, the file extension is mapped to a MIME type, because that makes things easy for everyone, but nothing says it has to be that way.
The HTTP headers can be wrong, the only definitive way to determine a file’s content type is to read it. This is why you can stick an image that has a mime type header of
application/octet-stream
in animg
tag and it’ll mostly work. Most binary formats will have some kind of magic number at the start to help determine it.Which is bad and wrong. Postel’s law has been considered a bad idea by Postel himself for a while. We shouldn’t let such fuzziness go through.
Meh, you shouldn’t need a sophisticated understanding of file formats and web server configuration to make a website, so some slack is imo a good thing. Maybe not as much as there is, but reading the head of an image file doesn’t seem that big a deal.
The unsophisticated solution is to map the file extension to the MIME type, which is done by default much of the time. If you do anything else, then we need to have a conversation about how.