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_SYSTEM | PHP 5.0.0 以降で利用可能 |
mime_magic.magicfile | "/path/to/php/magic.mime" | PHP_INI_SYSTEM | PHP 4.3.0 以降で利用可能 |
PHP_INI_* 定数の詳細および定義については 付録 G. php.ini ディレクティブ を参照してください。
以下に設定ディレクティブに関する 簡単な説明を示します。
リソース型
リソース型は定義されていません。定義済み定数
定数は定義されていません。目次
- mime_content_type — ファイルの MIME Content-type を検出する (非推奨)
メディアタイプ
(Mimetype から転送)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2024/05/24 02:10 UTC 版)
メディアタイプ(日: メディア型[1],英: Media Type(s))は、ファイルやインターネット上で転送されるコンテンツの形式を表現する識別子である。MIMEタイプや要素タイプ (Content type)とも表記される。text/plainのように、スラッシュで区切る表記が特徴的である。
注釈
- ^ 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] - ^ 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] - ^ 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]
出典
- ^ a b c d e f g JIS X 5810-2:2008「多目的インターネットメール拡張 (MIME) ―第2部: メディア型」(日本産業標準調査会、経済産業省)
- ^ "Media Types". Hypertext Transfer Protocol -- HTTP/1.0 (英語). May 1996. sec. 3.6. doi:10.17487/RFC1945. RFC 1945。
- ^ “HTML 4.01 Specification” (1999年12月24日). 2017年2月2日閲覧。
- ^ 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".
- ^ “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.”
- ^ Daniel Leidert, Egon Willighagen (2007年). “The chemical-mime-data project”. 2016年10月8日時点のオリジナルよりアーカイブ。2016年4月28日閲覧。
- ^ “Chemical MIME Home page”. 2019年5月11日閲覧。
- ^ 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 .
- ^ a b c d e f g Media Type Specifications and Registration Procedures (英語). January 2013. doi:10.17487/RFC6838. RFC 6838。
- ^ Berjon, Robin (2014年5月14日). “application/x-www-form-urlencoded” (英語). IANA. 2017年3月26日閲覧。
- 1 メディアタイプとは
- 2 メディアタイプの概要
- 3 名称について
- 4 関連項目
- 5 外部リンク
- Mimetypeのページへのリンク