I have this code, to receive image from another server and save it to disk. But the file is shorter than the original and contains header like this:
HTTP/1.1 200 OK
Date: Sat, 21 Sep 2002 14:39:43 GMT
Server: Apache/1.3.26 (Unix) PHP/4.2.3
Last-Modified: Fri, 20 Sep 2002 19:44:44 GMT
ETag: "13785a-ace8-3d8b7aac"
Accept-Ranges: bytes
Content-Length: 44264
Connection: close
Content-Type: image/jpeg
<?php
$pic="/004.jpg";
$str="GET ".$pic." HTTP/1.1
Connection: Keep-Alive
Host: www.google.com
Referer: http://www.domain.com/index.html\n\n
";
$fp = fsockopen ("www.domain.com", 80);
fputs ($fp, $str);
while (!feof($fp))
{
$data.=fgets ($fp,9999);
}
fclose ($fp);
$fr= fopen ("image.jpg","w+");
fputs ($fr,$data);
?>
Is it possible to get the file like this? I use fsockopen, because I need to send referer by request