开发者

Effects of using the wrong image headers for echo file_get_contents('someImageFile.ext')

It looks like it does not matter what image headers I use for spitting out via php script an image file with unknown extension, call it .ext

Are there any actual effects? (Is PHP silently converting it, or byp开发者_运维百科assing the format?)


PHP is most certainly not silently converting anything. It's the browser trying its best to interpret what it got served. Most browsers are likely not even paying that much attention to either the Content-Type header or the extension and just try to identify the file by its content.


Is the output you get the output you expect?

Maybe the script is outputting an error or the function you are using isn't binary safe, I'm guessing from your tags that you are using file_get_contents but what you may be looking for is fpassthru?

Try opening the file in your browser without setting headers or set a standard html/text header, see if something curious is happening.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜