mzur/guess-mime
最新稳定版本:v1.0
Composer 安装命令:
composer require mzur/guess-mime
包简介
Guess the MIME type from the file extension (Linux only).
README 文档
README
Abandoned: Use league/mime-type-detection instead.
Guess the MIME type from the file extension (Linux only). This can be handy if the file does not exist or cannot be accessed.
Warning: This package should not be used if the file actually exists and can be accessed (e.g. to check user-uploaded files). Use finfo_file for that.
Installation
composer require mzur/guess-mime
By default this package requires the /etc/mime.types file to be present. It can be installed e.g. with the mime-support package (Ubuntu) or the mailcap package (Alpine). A different file can be configured, too (see below).
Usage
use Mzur\GuessMIME\GuessMIME; $gm = new GuessMIME; $mime = $gm->guess('image.jpg'); var_dump($mime); // image/jpeg
If a MIME type cannot be guessed, application/octet-stream is returned. You can also limit the available MIME types, use a different MIME type database file (default: /etc/mime.types) and use a strict check that returns null if the MIME type cannot be guessed:
use Mzur\GuessMIME\GuessMIME; // Limit detection to image/jpeg and use a different database file. $gm = new GuessMIME(['image/jpeg'], '/home/user/.mime.types'); // Default MIME type. $mime = $gm->guess('image.png'); var_dump($mime); // application/octet-stream // Use strict check. $mime = $gm->guess('image.png', true); var_dump($mime); // null
统计信息
- 总下载量: 441
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-03