通过 PHP 获取 MIME 类型 [英] Get MIME Type via PHP

查看:26
本文介绍了通过 PHP 获取 MIME 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在本地访问文件,我需要获取它们的 MIME 类型.在 WAMP/LAMP、CodeIgniter 和 Zend 库中工作.获取 MIME 类型信息的最佳方法是什么?

I have local access to files, which I need to get their MIME types. Working in WAMP/LAMP, CodeIgniter, and Zend libraries. What's the best way to get MIME type information?

推荐答案

没有简单的方法.你可以试试:
http://www.php.net/manual/en/function.finfo-file.php

There's no easy way. You could try:
http://www.php.net/manual/en/function.finfo-file.php

// return mime type ala mimetype extension
$finfo = finfo_open(FILEINFO_MIME_TYPE);

当然,这假设您可以安装 PECL 扩展.

Of course, this assumes you can install PECL extensions.

这篇关于通过 PHP 获取 MIME 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆