File Types
In short: Categories of files that determine how their content is structured and which programs can open them — e.g. text, image, video, or archive.
In more detail: The file type is usually signalled via the file extension (.txt, .jpg, .zip), but can only be reliably determined via the actual byte content (magic numbers/signature at the start of the file) — a renamed file keeps its real type, even if the extension suggests otherwise.
In Depth
A simple example of the difference between file extension and real type: a PNG image always starts internally with the same eight bytes (89 50 4E 47 0D 0A 1A 0A) — no matter what the file is called. If you rename image.png to image.txt, the content remains a valid PNG; only programs that blindly rely on the extension would incorrectly treat it as a text file.
Rough categories of file types:
- Text-based: human-readable as plain text, e.g.
.txt,.md,.csv, JSON, XML. - Binary: only sensibly interpretable with a matching program, e.g. images (
.png,.jpg), videos, compiled programs. - Archives/containers: bundle or compress several files into one, e.g. ZIP,
.tar. - Structured Office formats: internally often themselves a ZIP archive of XML files, e.g.
.docx,.xlsx.
Many security problems arise exactly at this point: an uploaded file with a .jpg extension whose actual content is executable code can be incorrectly classified as harmless by a server that only checks the extension — which is why robust upload systems additionally check the real signature at the start of the file.
See also: Files