Re: Writing remote data to local file

From: Date: Thu, 08 May 2003 15:04:28 +0000
Subject: Re: Writing remote data to local file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-146851@lists.php.net to get a copy of this message
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.... | $localfile = fopen('test.txt','w'); | | fwrite($localfile,"<?php include '$remotefile'; ?>"); | | fclose($localfile); | | mysql_query("LOAD DATA INFILE LOCAL '/home/dave/public_html/test.txt' INTO TABLE shows FIELDS TERMINATED BY '/'"); However, the data that was entered into the database was the text of the include rather than the result of it. This makes sense, but I've gotten no farther. Any real help would be appreciated.

« previous php.general (#146851) next »