开发者

Get_File_contents and MINE TYPE

<?php
$file = file_get_contents('http://domain.com/background.gif开发者_StackOverflow社区');
echo $file;
?>

it echo a very long string(GIF89aÅÕ2cŒ®³¾J}BvUyš±µÁJr•O€d,,,,), not a image, how to fix it?


You need to specify content-type HTTP header:

header('Content-type: image/gif');

Otherwise browser treats output as a regular text/html web page.

Note, that headers should be sent before any output of your PHP script. Se this article for more info about headers.


header('Content-type:image/gif");

insert this before echo

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜