brandembassy/file-type-detector 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

brandembassy/file-type-detector

最新稳定版本:2.3.3

Composer 安装命令:

composer require brandembassy/file-type-detector

包简介

Detects file type by filename or content and generates correct mimetype. Forked from https://github.com/wapmorgan/FileTypeDetector

README 文档

README

Project forked from https://github.com/wapmorgan/FileTypeDetector

File Type Detector

Files type detector based on file name extension or file content (binary content).

File Type detection

  • Detection by file name: Detector::detectByFilename(...filename...): array|boolean
  • Detection by file content or stream content: Detector::detectByContent(...filename/resource...): array|boolean

Both functions will return an array with following elements in case of success:

  • [0] - Type of file (Detector::AUDIO and so on)
  • [1] - Format of file (Detector::MP3 and so on)
  • [2] - Mime type of file ('audio/mpeg' for example)

In case of failure it will return false.

Example:

$type = wapmorgan\FileTypeDetector\Detector::detectByFilename($filename);
// or
$type = wapmorgan\FileTypeDetector\Detector::detectByContent('file-without-extension');
// or
$type = wapmorgan\FileTypeDetector\Detector::detectByContent(fopen('http://somedomain/somepath', 'r'));

Mimetype resolving

To get correct mimetype for file only there is getMimeType($file) function.

$mime = wapmorgan\FileTypeDetector\Detector::getMimeType($file);
// or
$mime = wapmorgan\FileTypeDetector\Detector::getMimeType(fopen('somefile', 'r'));

Installation

composer require brandembassy/file-type-detector

统计信息

  • 总下载量: 207.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-18