定制 mzur/guess-mime 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mzur/guess-mime

最新稳定版本:v1.0

Composer 安装命令:

composer require mzur/guess-mime

包简介

Guess the MIME type from the file extension (Linux only).

README 文档

README

Tests

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固