PHP中如何实现多种方式解析文件的MIME类型?

2026-05-22 13:308阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1013个文字,预计阅读时间需要5分钟。

PHP中如何实现多种方式解析文件的MIME类型?

原文:本文实例讲述了PHP获取文件MIME类型的几种方法。分享给广大用户提供参考。具体如下:

1.使用 mime_content_type() 方法

string mime_content_type(string $filename)Returns the MIME content type for a file as determined by the server.

改写后:PHP获取文件MIME类型的方法包括:

1.通过 mime_content_type() 函数

函数:mime_content_type(string $filename)功能:返回服务器确定的文件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 方法代替。

阅读全文

本文共计1013个文字,预计阅读时间需要5分钟。

PHP中如何实现多种方式解析文件的MIME类型?

原文:本文实例讲述了PHP获取文件MIME类型的几种方法。分享给广大用户提供参考。具体如下:

1.使用 mime_content_type() 方法

string mime_content_type(string $filename)Returns the MIME content type for a file as determined by the server.

改写后:PHP获取文件MIME类型的方法包括:

1.通过 mime_content_type() 函数

函数:mime_content_type(string $filename)功能:返回服务器确定的文件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 方法代替。

阅读全文