fread via ftp to NT fails
| From: | Mark Heintz PHP Mailing Lists | Date: | Mon, 21 May 2001 17:51:41 +0000 |
| Subject: | fread via ftp to NT fails | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-53760@lists.php.net to get a copy of this message | ||
I'm attempting to read a file from a remote server and save it to a
variable. The code below works fine if the remote server is unix based,
but fails with the server I actually need to retrieve data from (NT4 SP4,
beyond my control). When trying to fread from the NT server,
$invoice_contents ends up being null ($invoice_contents === '').
if( !($fd = fopen("anonymous:guest@ftp.myhost.com/pub/readme.txt", "rb"))){
$error = true;
$error_msg = "Unable to connect to server.";
}
else {
$i = 0;
do {
$invoice_contents = fread($fd, 100000);
$i++;
} while( $invoice_contents == "" && $i < 2 );
fclose($fd);
}
Here's the interesting part: If I comment out the fread and run this
code, there is no visable difference in the ftp logs on the NT server (a
USER, PASS, and sent <path/file> appear for the connection). Am I
correct in interpreting this as the file is being sent immediately (after
the fopen) rather than at the fread? Has anybody else encountered this?
Thanks,
mth