RE: [PHP] Writing remote data to local file
| From: | Ford, Mike [LSS] | Date: | Thu, 08 May 2003 15:33:18 +0000 |
| Subject: | RE: [PHP] Writing remote data to local file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146859@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Dave Rosenberg [mailto:daverose@arches.uga.edu]
> Sent: 08 May 2003 16:24
> To: php-general@lists.php.net
> Subject: Re: [PHP] Writing remote data to local file
>
>
> Mike Ford wrote:
> >>-----Original Message-----
> >>From: Dave Rosenberg [mailto:daverose@arches.uga.edu]
> >>Sent: 08 May 2003 16:04
> >>To: php-general@lists.php.net
> >>Subject: Re: [PHP] Writing remote data to local file
> >>
> >>
> >>Jason Wong wrote:
> >>
> >>>On Thursday 08 May 2003 20:46, Dave Rosenberg wrote:
> >>>
> >>>
> >>>>I'm trying to write the data from a remote file (on the
> >>>
> >>web) to a local
> >>
> >>>>file (test.txt). I tried the code below, but rather than
> >>>
> >>the contents
> >>
> >>>>of the remote file being written to the local file, the local file
> >>>>contains a resource ID. I'd appreciate a push in the right
> >>>
> >>direction as
> >>
> >>>> far as pulling all the data from the remote file to the
> text file.
> >>>>
> >>>>| $remotefile =
> >>>>fopen('http://mydomain.org/testo.html','r');
> >>>>|
> >>>>| $localfile =
> >>>>fopen('/home/dave/public_html/test.txt','w');
> >>>>|
> >>>>| fwrite($localfile,$remotefile);
> >>>>|
> >>>>| fclose($localfile);
> >>>>|
> >>>>| fclose($remotefile);
> >>>
> >>>
> >>>Lookup each of the above functions in the manual and see
> >>
> >>_what arguments_ they
> >>
> >>>take and what they _return_. Then examine and try the
> >>
> >>examples given for each
> >>
> >>>of the functions and understand how they work.
> >>>
> >>
> >>Obviously that's the first thing I did, but they do not offer any
> >>guidance beyond where I've gotten. I also tried this....
> >
> >
> > Well, obviously you did not look at the right bits, so try
> this little quiz:
> >
> > (1) what does fopen return?
> >
> > (2) what does fwrite() expect its second argument to be?
> >
> > (3) are these the same?
> >
>
> No,
Correct. So now you need to work out how to use the File Resource returned in (1) to get the text
string required for (2). Well, you clearly know how to use the File Resource returned into
$localfile to *write* some text to the associated file, so a little bit of cogitating should quickly
tell you how to use the File Resource returned into $remotefile to *read* some text from the
associated file.
> or I wouldn't be asking. I was looking for some assistance.
> Judging by these two responses, I guess this is not the right
> place to
> ask questions?
Of course it is -- we were just trying to assist you by giving you a fishing rod rather than a fish!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211