File Extension vs MIME Type
People think the ending of a file name says what the file is, and it does not. The extension is a hint that your own computer reads to pick an app. On the web, the browser trusts the media type the server sends instead. When the two disagree, the browser goes with the server's label.
File Extension
The ending after the dot in a file name, like .pdf. It hints at what kind of file it is.
A file extension is the short ending on a file name, after the last dot. In report.pdf, the extension is .pdf. It hints at the file's format. Your computer uses it to pick which app opens the file. It is only a hint, though. The real format is in the bytes inside.
Media Type (MIME Type)
A label like image/png. It names the kind of data a server sends.
A MIME type is a short label that names the kind of data being sent. It has two parts with a slash, like text/html or image/png. Web servers send it with every file, in a header called Content-Type. The browser reads it to decide what to do. It may show a page, play a video or download a file. The list of official types is kept by IANA.
In one line
- File Extension
- The ending after the dot in a file name, like .pdf. It hints at what kind of file it is.
- Media Type (MIME Type)
- A label like image/png. It names the kind of data a server sends.