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
精彩评论