Re: save file from outside url
| From: | Jeremiah Breindel | Date: | Mon, 09 Dec 2002 15:44:03 +0000 |
| Subject: | Re: save file from outside url | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127510@lists.php.net to get a copy of this message | ||
Ok. I stripped the needed code out of the image creation script and
inserted it into my update script. It works great as long as I hard
code in the filename of the file that is being saved to the server.
When I pass the image creation function a variable for the filename it
tells me "invalid filename", although I am echoing it out right before
and it looks perfect. Any thoughts?
Jason Wong wrote:
>
> 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.
> */