本文实例讲述了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程序设计有所帮助。