Retrieving text file
| From: | Michael Benbow | Date: | Tue, 30 Oct 2001 00:23:38 +0000 |
| Subject: | Retrieving text file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-72798@lists.php.net to get a copy of this message | ||
Hi All,
I am completely new to all this, so please bare with me. I have
permission to use another person's text file which resides on his
server. Currently I manually download the file, process it in Excel,
then upload it into my MySQL database. I want to try to automate this
process, and the first step I see if getting the file from his server
onto mine for processing. I will be using a cron job for this.
This is what I currently have, but I get errors...
$WebFile="http://www.somesite.com/somefile.txt";
$LocalFile="/path/to/somefile.txt";
$handle = fopen ($WebFile, "r");
$outhandle=fopen ($LocalFile,"w");
while (!feof($handle)) {
$buffer=fread($handle,4096);
fputs($outhandle,$buffer);
}
fclose($handle);
fclose($outhandle);
When I try running this I get error after error:
Warning: fopen("http://www.somesite.com/somefile.txt","r")
- No error in
trial.php on line 5
Warning: Supplied argument is not a valid File-Handle resource in
trial.php on line 7
Warning: Supplied argument is not a valid File-Handle resource in
trial.php on line 8
The last two lines repeat themselves until the script times out.
Help! I am desperate!! The file definently exists but I am stuck.
Thank you,
Michael.