よく使うContent-Typeと、Content-Dispositionの指定方法です。
ブラウザ上で表示するか、ダウンロードさせるかの指示
操作 | header |
---|---|
ブラウザ表示 | content-disposition: inline; |
ダウンロード | content-disposition: attachment; filename*=UTF-8''URLエンコードしたファイル名 |
よく使う拡張子とContentTypeの一覧
拡張子 | header |
---|---|
不明 | content-type: application/octet-stream |
.txt | content-type: text/plain |
.html | content-type: text/html |
.css | content-type: text/css |
.js | content-type: text/javascript |
.csv | content-type: text/csv |
.xml | content-type: application/xml |
.json | content-type: application/json |
.zip | content-type: application/zip |
.jpg | content-type: image/jpeg |
.jpeg | content-type: image/jpeg |
.png | content-type: image/png |
.gif | content-type: image/gif |
.bmp | content-type: image/bmp |
.tif | content-type: image/tiff |
.tiff | content-type: image/tiff |
.svg | content-type: image/svg+xml |
content-type: application/pdf | |
.xls | content-type: application/vnd.ms-excel |
.xlsx | content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
.doc | content-type: application/msword |
.docx | content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.ppt | content-type: application/vnd.ms-powerpoint |
.pptx | content-type: application/vnd.openxmlformats-officedocument.presentationml.presentation |