MIME タイプ
目次
MIME タイプ?
MIME タイプ (MIME メディアタイプ) はファイル (リソース) の種類を指定するための標準的な識別子です。主に下記の用途で使用します。
- メールの添付ファイル等のファイルの種類を指定する (
Content-Type
) - Web 上のファイルの種類を指定する (HTTP レスポンスヘッダの
Content-Type
)
MIME タイプの例
種類 | 拡張子 | MIME タイプ |
---|---|---|
HTML | .html | text/html |
CSS | .css | text/css |
JavaScript | .js | text/javascript |
JSON | .json | application/json |
XML | .xml | application/xml |
GIF | .gif | image/gif |
PNG | .png | image/png |
JPEG | .jpg | image/jpeg |
SVG | .svg | image/svg+xml |
WEBP | .webp | image/webp |
テキスト | .txt | text/plain |
CSV | .csv | text/csv |
MP3 | .mp3 | audio/mpeg |
MP4 | .mp4 | video/mp4 |
application/pdf | ||
ZIP | .zip | application/zip |
Word | .doc | application/msword |
Word | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
Excel | .xls | application/vnd.ms-excel |
Excel | .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
PowerPoint | .ppt | application/vnd.ms-powerpoint |
PowerPoint | .pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
MIME タイプの例 (JSON / オブジェクト)
{
"html": "text/html",
"css": "text/css",
"js": "text/javascript",
"json": "application/json",
"xml": "application/xml",
"gif": "image/gif",
"png": "image/png",
"jpg": "image/jpeg",
"svg": "image/svg+xml",
"webp": "image/webp",
"txt": "text/plain",
"csv": "text/csv",
"mp3": "audio/mpeg",
"mp4": "video/mp4",
"pdf": "application/pdf",
"zip": "application/zip",
"doc": "application/msword",
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xls": "application/vnd.ms-excel",
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"ppt": "application/vnd.ms-powerpoint",
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation"
}
MIME タイプの例 (PHP / 連想配列)
$types = array(
"html" => "text/html",
"css" => "text/css",
"js" => "text/javascript",
"json" => "application/json",
"xml" => "application/xml",
"gif" => "image/gif",
"png" => "image/png",
"jpg" => "image/jpeg",
"svg" => "image/svg+xml",
"webp" => "image/webp",
"txt" => "text/plain",
"csv" => "text/csv",
"mp3" => "audio/mpeg",
"mp4" => "video/mp4",
"pdf" => "application/pdf",
"zip" => "application/zip",
"doc" => "application/msword",
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xls" => "application/vnd.ms-excel",
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"ppt" => "application/vnd.ms-powerpoint",
"pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
);