MIME (Multipurpose Internet Mail Extensions) 是描述消息内容类型的标准,用来表示文档、文件或字节流的性质和格式。
MIME 消息能包含文本、图像、音频、视频以及其他应用程序专用的数据。
浏览器通常使用 MIME 类型(而不是文件扩展名)来确定如何处理URL,因此 We b服务器在响应头中添加正确的 MIME 类型非常重要。如果配置不正确,浏览器可能会无法解析文件内容,网站将无法正常工作,并且下载的文件也会被错误处理。
语法
MIME 类型通用结构:
type/subtype
MIME 的组成结构非常简单,由类型与子类型两个字符串中间用 / 分隔而组成,不允许有空格。type 表示可以被分多个子类的独立类别,subtype 表示细分后的每个类型。
MIME类型对大小写不敏感,但是传统写法都是小写。
两种主要的 MIME 类型在默认类型中扮演了重要的角色:
text/plain 表示文本文件的默认值。
application/octet-stream 表示所有其他情况的默认值。
常见的 MIME 类型
超文本标记语言文本 .html、.html:text/html
普通文本 .txt: text/plain
RTF 文本 .rtf: application/rtf
GIF 图形 .gif: image/gif
JPEG 图形 .jpeg、.jpg: image/jpeg
au 声音文件 .au: audio/basic
MIDI 音乐文件 mid、.midi: audio/midi、audio/x-midi
RealAudio 音乐文件 .ra、.ram: audio/x-pn-realaudio
MPEG 文件 .mpg、.mpeg: video/mpeg
AVI 文件 .avi: video/x-msvideo
GZIP 文件 .gz: application/x-gzip
TAR 文件 .tar: application/x-tar
类型 | 描述 | 典型示例 |
---|---|---|
text | 表明文件是普通文本,理论上是人类可读 | text/plain , text/html , text/css, text/javascript |
image | 表明是某种图像。不包括视频,但是动态图(比如动态gif)也使用image类型 | image/gif , image/png , image/jpeg , image/bmp , image/webp , image/x-icon , image/vnd.microsoft.icon |
audio | 表明是某种音频文件 | audio/midi , audio/mpeg, audio/webm, audio/ogg, audio/wav |
video | 表明是某种视频文件 | video/webm , video/ogg |
application | 表明是某种二进制数据 |
|
MIME 对照表
媒体类型 | 文件扩展名 | 说明 |
---|---|---|
application/msword | doc | 微软 Office Word 格式(Microsoft Word 97 - 2004 document) |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | docx | 微软 Office Word 文档格式 |
application/vnd.ms-excel | xls | 微软 Office Excel 格式(Microsoft Excel 97 - 2004 Workbook |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | xlsx | 微软 Office Excel 文档格式 |
application/vnd.ms-powerpoint | ppt | 微软 Office PowerPoint 格式(Microsoft PowerPoint 97 - 2003 演示文稿) |
application/vnd.openxmlformats-officedocument.presentationml.presentation | pptx | 微软 Office PowerPoint 文稿格式 |
application/x-gzip | gz, gzip | GZ 压缩文件格式 |
application/zip | zip, 7zip | ZIP 压缩文件格式 |
application/rar | rar | RAR 压缩文件格式 |
application/x-tar | tar, tgz | TAR 压缩文件格式 |
application/pdf | PDF 是 Portable Document Format 的简称,即便携式文档格式 | |
application/rtf | rtf | RTF 是指 Rich Text Format,即通常所说的富文本格式 |
image/gif | gif | GIF 图像格式 |
image/jpeg | jpg, jpeg | JPG(JPEG) 图像格式 |
image/jp2 | jpg2 | JPG2 图像格式 |
image/png | png | PNG 图像格式 |
image/tiff | tif, tiff | TIF(TIFF) 图像格式 |
image/bmp | bmp | BMP 图像格式(位图格式) |
image/svg+xml | svg, svgz | SVG 图像格式 |
image/webp | webp | WebP 图像格式 |
image/x-icon | ico | ico 图像格式,通常用于浏览器 Favicon 图标 |
application/kswps | wps | 金山 Office 文字排版文件格式 |
application/kset | et | 金山 Office 表格文件格式 |
application/ksdps | dps | 金山 Office 演示文稿格式 |
application/x-photoshop | psd | Photoshop 源文件格式 |
application/x-coreldraw | cdr | Coreldraw 源文件格式 |
application/x-shockwave-flash | swf | Adobe Flash 源文件格式 |
text/plain | txt | 普通文本格式 |
application/x-javascript | js | Javascript 文件类型 |
text/javascript | js | 表示 Javascript 脚本文件 |
text/css | css | 表示 CSS 样式表 |
text/html | htm, html, shtml | HTML 文件格式 |
application/xhtml+xml | xht, xhtml | XHTML 文件格式 |
text/xml | xml | XML 文件格式 |
text/x-vcard | vcf | VCF 文件格式 |
application/x-httpd-php | php, php3, php4, phtml | PHP 文件格式 |
application/java-archive | jar | Java 归档文件格式 |
application/vnd.android.package-archive | apk | Android 平台包文件格式 |
application/octet-stream | exe | Windows 系统可执行文件格式 |
application/x-x509-user-cert | crt, pem | PEM 文件格式 |
audio/mpeg | mp3 | mpeg 音频格式 |
audio/midi | mid, midi | mid 音频格式 |
audio/x-wav | wav | wav 音频格式 |
audio/x-mpegurl | m3u | m3u 音频格式 |
audio/x-m4a | m4a | m4a 音频格式 |
audio/ogg | ogg | ogg 音频格式 |
audio/x-realaudio | ra | Real Audio 音频格式 |
video/mp4 | mp4 | mp4 视频格式 |
video/mpeg | mpg, mpe, mpeg | mpeg 视频格式 |
video/quicktime | qt, mov | QuickTime 视频格式 |
video/x-m4v | m4v | m4v 视频格式 |
video/x-ms-wmv |
相关导航
您将离开本站并访问
|