Re: save file from outside url
| From: | Jeremiah Breindel | Date: | Mon, 09 Dec 2002 17:16:00 +0000 |
| Subject: | Re: save file from outside url | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127530@lists.php.net to get a copy of this message | ||
I figured it out! Variable scope problem! Thanks for all your help!
"Jeremiah Breindel" <jeremiah@jkdesigns.com> wrote in message
news:20021206210638.71804.qmail@pb1.pair.com...
> I am trying to save a dynamically generated image on an outside server to
a
> local file on my server using the code below:
>
> $fc = fopen($image_filename, "wb");
> $file = fopen ($image_url, "rb");
>
> if (!$file) {
> echo "<p>Unable to open remote file.\n";
> exit;
> }else{
> while (!feof ($file)) {
> $line = fread ($file, 1028);
> fwrite($fc,$line);
> }
> }
> fclose($fc);
> fclose($file);
>
>
> $image_filename is a locally referred to file, such as
"../images/file1.png"
> and $image_url is an absolute address, such as
> "http://www.whatever.com/imagecreate.php".
>
> Instead of saving when I run the script through a browser, the image
> displays within the browser, and the script creates a file containing only
> "427" on the server. Any ideas why or what I can do to correct this?
>
> Jeremiah
>
>