Re: Writing remote data to local file

From: Date: Thu, 08 May 2003 16:20:20 +0000
Subject: Re: Writing remote data to local file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146872@lists.php.net to get a copy of this message
At 14:46 08.05.2003, Dave Rosenberg spoke out and said: --------------------[snip]-------------------- >Hi, > >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); > --------------------[snip]-------------------- Well, if you'*d rather need a fish... $remotefile = fopen('http://mydomain.org/testo.html','r'); $localfile = fopen('/home/dave/public_html/test.txt','w'); while ($buffer = fread($remotefile, 4096)) fwrite($localfile,$buffer); fclose($localfile); fclose($remotefile); Should work... -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#146872) next »