无为清净楼资源网 Design By www.qnjia.com

本文实例讲述了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.  

<";"去掉,然后重启apache。

<","去掉,然后重启apache

<?php 
$image = exif_imagetype('1.jpg'); 
$mime_type = image_type_to_mime_type($image); 
echo $mime_type; // image/jpeg 
?>

Tips:如果使用文件名的后缀来判断,因为文件后缀是可以修改的,所以使用文件后缀来判断会不准确。

希望本文所述对大家的php程序设计有所帮助。

标签:
php,获取,文件,mime类型,方法

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com