tags:

views:

10

answers:

2
<?php
$file = file_get_contents('http://domain.com/background.gif');
echo $file;
?>

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

+1  A: 

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.

Kel
+1  A: 
header('Content-type:image/gif");

insert this before echo

Ygam