scriptje:
$host = "server.com";
$uri = "/mms/bin7866.jpg";
$sock = fsockopen($host, 80, $errno, $errstr, 5);
fputs($sock, "GET ".$uri." HTTP/1.1\r\n");
fputs($sock, "Host: ".$host."\r\n");
fputs($sock, "Connection: close\r\n\r\n");
while(!feof($sock)) {
$handle2 .= fgets($sock, 4096);}
fclose($sock);
//echo $handle2; handle2 contains what i receive from the HTTP GET
$handle = explode ("Connection: close",$handle2);
echo "<br>";
echo $handle[1]; // Stripped to obtain the JPG info
$file = "../Graph/Pics/aaaa.jpg";
if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $handle[1])) { echo "Cannot write to file"; }
fclose($file_handle);
MY get HTTP
HTTP/1.1 200 OK Date: Tue, 14 Jun 2005 16:27:30 GMT Server: Apache/1.3.26 (Unix) Resin/2.1.3 Last-Modified: Wed, 08 Jun 2005 12:57:37 GMT ETag: "1c263-65dd-42a6eb41" Accept-Ranges: bytes Content-Length: 26077 Connection: close Content-Type: image/jpeg ÿØÿàJFIFÿÛC #%$""!&+7/&)4)!"0A149;>>>%.DIC;ÿÛC ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀwô"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—
I drop the stuff with close connection and write this to my server in a new file but it doesnt show the JPG correct:
Content-Type: image/jpeg ÿØÿàJFIFÿÛC #%$""!&+7/&)4)!"0A149;>>>%.DIC;ÿÛC ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀwô"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢
Any idea what i'm doing wrong?