aedart/athenaeum-mime-types

8.10.0 2024-09-04 09:18 UTC

README

基于“配置文件”的MIME类型检测器,它使用字符串或资源作为样本。

use Aedart\MimeTypes\Detector;

$file = fopen('my-picture.jpg', 'rb');

// Detect mime-type by only reading xx-bytes from file...
$mimeType = (new Detector())->detect($file);
fclose($file);

print_r($mimeType);

输出示例

Aedart\MimeTypes\MimeType Object
(
    [description] => JPEG image data, JFIF standard 1.01, resolution (DPI),...
    [mime] => image/jpeg; charset=binary
    [type] => image/jpeg
    [encoding] => binary
    [known_extensions] => Array
        (
            [0] => jpeg
            [1] => jpg
            [2] => jpe
            [3] => jfif
        )
)

幕后,默认配置文件驱动程序使用PHP的文件信息扩展

文档

请阅读官方文档以获取更多信息。

仓库

单一代码库位于github.com/aedart/athenaeum

版本控制

此包遵循语义版本控制2.0.0

许可证

BSD-3-Clause,请阅读包含在此包中的LICENSE文件