获取图像的mime类型 [英] get mime type of image

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

问题描述

我已经在数据类型为varchar(20)的表中创建了一个mime_type字段.现在我想通过使用代码

i have create a field mime_type in table with datatype varchar(20). now i want to save mime type by using code

$imgdata = base64_decode($arrayA[7]);

$f = finfo_open();

$mime_type = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE);

arrayA [7]是图像存储的位置,此mime_type被保存为表

arrayA[7] is where image store , after this mime_type is save in the table as

它不显示图像

推荐答案

以下函数返回文件的MIME内容类型,其中$filename是文件的路径.

Below function returns the MIME content type for a file, where $filename is path to the file.

string mime_content_type (string $filename)

假设我们有以下代码,

echo mime_content_type('php.gif')

输出将为 image/gif

Output will be image/gif

更新

finfo缓冲区,这将对您有帮助.

finfo-buffer this will help you in your case.

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

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