Mimetypeとは? わかりやすく解説

Mimetype 関数

導入


警告
この拡張モジュールは廃止予定です。PECL の Fileinfo 拡張モジュールが、同等の機能(に加えてそれ以上の機能)を よりきれいな方法で提供しています。

このモジュールの関数は、ファイル内の特定の位置にある magic バイトシーケンスを探すことにより ファイルの content type とエンコーディングの推定を試みます。 この手法は失敗する可能性がないわけではありませんが、経験上 非常に良い結果が得られます。
この拡張モジュールは、Apache の mod_mime_magic から派生したものです。 mod_mime_magic は、Ian F. Darwin により管理されている file コマンドに基づいています。 より詳細な履歴や著作権についてはソースコードを参照してください。

要件

外部ライブラリを必要としません。

インストール手順

mime-type 関数をサポートするためには、configure スイッチ --with-mime-magic を付けて PHP をコンパイルする必要があります。この拡張モジュールは、 Apache httpd と共に配布されているシンプル版の magic ファイルのコピーを必要とします。
注意: configure オプションは、PHP 4.3.2 以降 --enable-mime-magic から --with-mime-magic に変更されています。
注意: この拡張モジュールには、付加機能が多くついた magic ファイルを処理する機能はありません(この magic ファイルは、標準的なLinuxディストリビューションに付属しており、 最近のバージョンの file コマンドで使用されている ようです)。
Win32 ユーザへの注意: このモジュールを Windows 環境で使用するには、バンドルされた magic.mime へのパスを php.ini に設定する必要 があります。
例 1228. magic.mime のパスの設定例

mime_magic.magicfile = "$PHP_INSTALL_DIR\magic.mime"

    


上の例の $PHP_INSTALL_DIR を実際の PHP のパス、例えば、c:\php に置き換えてください。

実行時設定

php.ini の設定により動作が変化します。
表 162. Mimetype 設定オプション
名前デフォルト変更の可否変更履歴
mime_magic.debug"0"PHP_INI_SYSTEMPHP 5.0.0 以降で利用可能
mime_magic.magicfile"/path/to/php/magic.mime"PHP_INI_SYSTEMPHP 4.3.0 以降で利用可能

PHP_INI_* 定数の詳細および定義については 付録 G. php.ini ディレクティブ を参照してください。
以下に設定ディレクティブに関する 簡単な説明を示します。
mime_magic.debug bool
デバッグを有効/無効にする
mime_magic.magicfile string
magic.mime ファイルへのパス

リソース型

リソース型は定義されていません。

定義済み定数

定数は定義されていません。

目次

mime_content_type — ファイルの MIME Content-type を検出する (非推奨)

メディアタイプ

(Mimetype から転送)

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2024/05/24 02:10 UTC 版)

メディアタイプ(日: メディア型[1]: Media Type(s))は、ファイルやインターネット上で転送されるコンテンツの形式を表現する識別子である。MIMEタイプ要素タイプ (Content type)とも表記される。text/plainのように、スラッシュで区切る表記が特徴的である。


注釈

  1. ^ RFC 6838 3. Registration Trees and Subtype NamesよりThe following subsections define registration "trees" that are distinguished by the use of faceted names, e.g., subtype names that begin with a "tree." prefix.[9]
  2. ^ RFC 6838 3.1. Standards TreeよりMedia types in the standards tree MUST NOT have faceted names, unless they are grandfathered in using the process described in Appendix A.[9]
  3. ^ RFC 6838 3.4. Unregistered x. TreeよりHowever, with the simplified registration procedures described above for vendor and personal trees, it should rarely, if ever, be necessary to use unregistered types. Therefore, use of types in the "x." tree is strongly discouraged.[9]

出典

  1. ^ a b c d e f g JIS X 5810-2:2008「多目的インターネットメール拡張 (MIME) ―第2部: メディア型」日本産業標準調査会経済産業省
  2. ^ "Media Types". Hypertext Transfer Protocol -- HTTP/1.0 (英語). May 1996. sec. 3.6. doi:10.17487/RFC1945. RFC 1945
  3. ^ HTML 4.01 Specification” (1999年12月24日). 2017年2月2日閲覧。
  4. ^ Media Type Registration Procedure (英語). March 1994. p. 1. doi:10.17487/RFC1590. RFC 1590. These types, previously called "MIME Types", are now called "Media Types".
  5. ^ MIME Sniffing Standard” (英語). WHATWG. 2017年3月26日閲覧。 “A MIME type is sometimes called an Internet media type in protocol literature, but consistently using the term MIME type avoids confusion with the use of "media type" as described in the Media Queries CSS specification.”
  6. ^ Daniel Leidert, Egon Willighagen (2007年). “The chemical-mime-data project”. 2016年10月8日時点のオリジナルよりアーカイブ。2016年4月28日閲覧。
  7. ^ Chemical MIME Home page”. 2019年5月11日閲覧。
  8. ^ S. Rzepa, Henry; Murray-Rust, Peter; J. Whitaker, Benjamin (1998-08-14). “The Application of Chemical Multipurpose Internet Mail Extensions (Chemical MIME) Internet Standards to Electronic Mail and World Wide Web Information Exchange”. Journal of Chemical Information and Modeling (American Chemical Society). doi:10.1021/ci9803233. https://pubs.acs.org/doi/10.1021/ci9803233. 
  9. ^ a b c d e f g Media Type Specifications and Registration Procedures (英語). January 2013. doi:10.17487/RFC6838. RFC 6838
  10. ^ Berjon, Robin (2014年5月14日). “application/x-www-form-urlencoded” (英語). IANA. 2017年3月26日閲覧。


「メディアタイプ」の続きの解説一覧


英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Mimetype」の関連用語

Mimetypeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Mimetypeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
PHP Documentation GroupPHP Documentation Group
Copyright © 1997 - 2024 by the PHP Documentation Group.
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのメディアタイプ (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2024 GRAS Group, Inc.RSS