前言
Content-Type(内容类型),一般是指网页中存在的 Content-Type,用于定义网络文件的类型和网页的编码,决定浏览器将以什么形式、什么编码读取这个文件,这就是经常看到一些 PHP 网页点击的结果却是下载一个文件或一张图片的原因。
Content-Type 标头告诉客户端实际返回的内容的内容类型。
例子:
一、图片类型的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
jpg | JPEG images | image/jpg |
jpeg | JPEG images | image/jpg |
bmp | Windows OS/2 Bitmap Graphics | image/bmp |
gif | Graphics Interchange Format (GIF) | image/gif |
ico | Icon format | image/vnd.microsoft.icon |
png | Portable Network Graphics | image/png |
svg | Scalable Vector Graphics (SVG) | image/svg+xml |
tif/tiff | Tagged Image File Format (TIFF) | image/tiff |
webp | WEBP image | image/webp |
二、文本文件类型的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
css | Cascading Style Sheets (CSS) | text/css |
csv | Comma-separated values (CSV) | text/csv |
htm | HyperText Markup Language (HTML) | text/html |
html | HyperText Markup Language (HTML) | text/html |
ics | iCalendar format | text/calendar |
js | JavaScript | text/javascript |
mjs | JavaScript module | text/javascript |
txt | Text, (generally ASCII or ISO 8859-n) | text/plain |
xml | XML | text/xml 代码对普通用户来说可读 (RFC 3023, section 3) |
三、视频的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
avi | AVI: Audio Video Interleave | video/x-msvideo |
3g2 | 3GPP2 video container | video/3gpp2 |
3gp | 3GPP video container | video/3gpp |
webm | WEBM video | video/webm |
ogv | OGG video | video/ogg |
mpeg | MPEG Video | video/mpeg |
四、音频的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
aac | AAC audio | audio/aac |
mp3 | MP3 audio | audio/mpeg |
oga | OGG audio | audio/ogg |
wav | Waveform | Audio Format audio/wav |
weba | WEBM audio | audio/webm |
.3gp | 3GPP audio container | audio/3gpp(若不含视频) |
.3g2 | 3GPP2 audio container | audio/3gpp2(若不含视频) |
midi | Musical Instrument Digital Interface (MIDI) | audio/x-midi |
mid | Musical Instrument Digital Interface (MIDI) | audio/midi |
| | |
五、字体的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
otf | OpenType font | font/otf |
ttf | TrueType Font | font/ttf |
woff | Web Open Font Format (WOFF) | font/woff |
woff2 | Web Open Font Format (WOFF) | font/woff2 |
六、其他情况下默认的MIME类型
扩展名 | 文档类型 | MIME类型 |
---|
asp | asp | text/asp |
jsp | jsp | text/html |
php | PHP | application/octet-stream |
abw | AbiWord document | application/x-abiword |
arc | Archive document (multiple files embedded) | application/x-freearc |
azw | Amazon Kindle eBook format | application/vnd.amazon.ebook |
bin | Any kind of binary data | application/octet-stream |
bz | BZip archive | application/x-bzip |
bz2 | BZip2 archive | application/x-bzip2 |
csh | C-Shell script | application/x-csh |
doc | Microsoft Word | application/msword |
docx | Microsoft Word (OpenXML) | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
eot | MS Embedded OpenType fonts | application/vnd.ms-fontobject |
epub | Electronic publication (EPUB) | application/epub+zip |
jar | Java Archive (JAR) | application/java-archive |
json | JSON format | application/json |
jsonld | JSON-LD format | application/ld+json |
mpkg | Apple Installer Package | application/vnd.apple.installer+xml |
odp | OpenDocument presentation document | application/vnd.oasis.opendocument.presentation |
ods | OpenDocument spreadsheet document | application/vnd.oasis.opendocument.spreadsheet |
odt | OpenDocument text document | application/vnd.oasis.opendocument.text |
pdf | Adobe Portable Document Format (PDF) | application/pdf |
ppt | Microsoft PowerPoint | application/vnd.ms-powerpoint |
pptx | Microsoft PowerPoint (OpenXML) | application/vnd.openxmlformats-officedocument.presentationml.presentation |
rar | RAR archive | application/x-rar-compressed |
rtf | Rich Text Format (RTF) | application/rtf |
sh | Bourne shell script | application/x-sh |
swf | Small web format (SWF) or Adobe Flash document | application/x-shockwave-flash |
tar | Tape Archive (TAR) | application/x-tar |
vsd | Microsoft Visio | application/vnd.visio |
xhtml | XHTML | application/xhtml+xml |
xls | Microsoft Excel | application/vnd.ms-excel |
xlsx | Microsoft Excel (OpenXML) | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
xml | XML | application/xml 代码对普通用户来说不可读 (RFC 3023, section 3) |
xul | XUL | application/vnd.mozilla.xul+xml |
zip | ZIP | archive application/zip |
7z | 7-zip archive | application/x-7z-compressed |