Date: 06/15/02
- Next message: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Previous message: Nathan Taylor: "Re: [PHP] Can't set a cookie?"
- In reply to: Jeff Bearer: "[PHP] saving a jpeg via HTTP"
- Next in thread: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Reply: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jun 15, 2002 at 11:15:42AM -0400, Jeff Bearer wrote:
> I'm trying to read it with fsockopen and writing it with fopen to the
> file but the file is no good when it's saved, I saw that it saved the
> http headers in there so I cut those out but still, the image wan't
> viewable.
Are you using the binary safe fread/fwrite()? Didn't forget to fclose()
the output file?
This works for me:
<?php
if($fi=fsockopen("host",80))
{
fputs($fi,"GET /image.gif HTTP/1.0\r\n\r\n");
while(!preg_match("/^\r?\n$/",fgets($fi,1024))); //skip headers
while(!feof($fi))
{
if($fo=fopen("/tmp/tmp.gif","w"))
{
while(!feof($fi))
{
fwrite($fo,fread($fi,65535));
}
fclose($fo);
}
}
fclose($fi);
}
?>
--Daniel Tryba
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Previous message: Nathan Taylor: "Re: [PHP] Can't set a cookie?"
- In reply to: Jeff Bearer: "[PHP] saving a jpeg via HTTP"
- Next in thread: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Reply: Daniel Tryba: "Re: [PHP] saving a jpeg via HTTP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

