如何用PHP实现多种方法获取文件MIME类型?
- 内容介绍
- 文章标签
- 相关推荐
本文共计1038个文字,预计阅读时间需要5分钟。
原文:本文实例讲述了PHP获取文件MIME类型的几种方法。分享给广大供大家参考。具体如下:
1.使用 mime_content_type() 方法
string mime_content_type(string $filename)Returns the MIME content type for a file as determined by the mime magic file on the server.改写后:本文提供PHP获取文件MIME类型的几种方法。供大家参考。具体方法包括:
1.通过 mime_content_type() 函数获取
函数:string mime_content_type(string $filename)功能:返回文件根据服务器上的mime魔术文件确定的MIME类型。本文实例讲述了php获取文件mime类型的方法。分享给大家供大家参考。具体如下:
1.使用 mime_content_type 方法
string mime_content_type ( string $filename )
Returns the MIME content type for a file as determined by using information from the magic.mime file.
<?php $mime_type = mime_content_type('1.jpg'); echo $mime_type; // image/jpeg ?>
但此方法在 php5.3 以上就被废弃了,官方建议使用 fileinfo 方法代替。
本文共计1038个文字,预计阅读时间需要5分钟。
原文:本文实例讲述了PHP获取文件MIME类型的几种方法。分享给广大供大家参考。具体如下:
1.使用 mime_content_type() 方法
string mime_content_type(string $filename)Returns the MIME content type for a file as determined by the mime magic file on the server.改写后:本文提供PHP获取文件MIME类型的几种方法。供大家参考。具体方法包括:
1.通过 mime_content_type() 函数获取
函数:string mime_content_type(string $filename)功能:返回文件根据服务器上的mime魔术文件确定的MIME类型。本文实例讲述了php获取文件mime类型的方法。分享给大家供大家参考。具体如下:
1.使用 mime_content_type 方法
string mime_content_type ( string $filename )
Returns the MIME content type for a file as determined by using information from the magic.mime file.
<?php $mime_type = mime_content_type('1.jpg'); echo $mime_type; // image/jpeg ?>
但此方法在 php5.3 以上就被废弃了,官方建议使用 fileinfo 方法代替。

