Re: File Copy
| From: | Henrik Hansen | Date: | Fri, 01 Mar 2002 10:46:15 +0000 |
| Subject: | Re: File Copy | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-86741@lists.php.net to get a copy of this message | ||
acd@cs.pdx.edu (Andy Delcambre) wrote:
> I am a complete php newbie but i have a quick question. I was wondering if
> there is a way to copy a file from a remote site to your local server? I
> want to grab a picture off of a site and store it locally to be displayed
> later. Thanks alot,
use the fopen function to save the image to your local site, ex:
$fp = fopen("http://site.com/image.gif",
"r");
$buffer = "";
while (!feof ($fp)) {
$buffer .= fgets($fp, 4096);
}
fclose($fp);
$fp = fopen("/local/file.gif", "wb");
fwrite($fp, $buffer);
fclose($fp);
untested but it should work (TM).
--
Henrik Hansen