简体   繁体   English

图像mime类型因我使用的PHP Server而异

[英]Image mime type is different based on which PHP Server I use

I have this image file that when I test in my local environment then PHP determines it is of type 我有这个映像文件,当我在本地环境中进行测试时,PHP确定它的类型

image/jpeg

However that same code and same image on my server gets detected as 但是,我的服务器上的相同代码和相同图像被检测为

application/octet-stream

What could be causing this behavior? 是什么导致这种现象?

Image Size: 2.31 MB 
Name: ^EC91F66F648FD45E7BF3BE9D2169E239D41E49B794EA71E326^pimgpsh_fullsize_distr (1).jpg

Local Environment 当地环境

PHP: 5.6.15

Live Environment 生活环境

PHP: 5.6.9

The issue is likely due to a difference with the mime magic file. 该问题可能是由于哑剧魔术文件的不同所致。 This file contains sequences that help detect which mime type a file is by reading the first few bytes. 该文件包含一些序列,这些序列可通过读取前几个字节来帮助检测文件是哪种MIME类型。

The fileinfo class, which is being used with your methods, can be given a path to the magic file, otherwise it has a process of searching for a mime magic file. 您的方法所使用的fileinfo类可以被赋予魔术文件的路径,否则它具有搜索mime魔术文件的过程。

If you want to set a specific magic file you can add this setting to your php.ini mime_magic.magicfile . 如果要设置特定的魔术文件,可以将此设置添加到php.ini mime_magic.magicfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM