Re: save file from outside url
| From: | Jason Wong | Date: | Sun, 08 Dec 2002 14:00:19 +0000 |
| Subject: | Re: save file from outside url | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127429@lists.php.net to get a copy of this message | ||
On Sunday 08 December 2002 00:47, Jeremiah Breindel wrote:
> Thanks for responing Jason!
>
> There is other code in there for updating some database entries and
> producing a confirmation page, but I had them working perfectly before I
> added the image code below. Only when acessing the outside script and
> saving to file did it start doing the odd things. I didn't write the image
> creation script, only hard coded in some values for font and bg colors in
> it. I have attached that script at the bottom of this, away from
> everything else. Maybe a header problem from that script? Any idea what
> 427 is from? Thanks for all your help!
> The $image_url is like this - "$rollover_image_url =
> "http://www.anysite.com//pngmake.php?msg=" .
> $rollover .
> "&rot=0&size=12&font=fonts/ARIAL.TTF";
Two things you need to do:
1) Plug the value of $rollover_image_url into a browser and satisfy yourself
that the resulting URL does indeed return a valid image, and hence said URL
is valid.
2) Plug in a known, static, valid URL (of an image -- actually it can be
anything it doesn't really matter) into your code below, and satisfy yourself
that the your code does work.
> > > 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);
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Chicago law prohibits eating in a place that is on fire.
*/