fread over ftp

From: Date: Wed, 21 Feb 2001 19:59:40 +0000
Subject: fread over ftp
Groups: php.general 
Request: Send a blank email to php-general+get-41046@lists.php.net to get a copy of this message
I'm having some trouble reading a text file from a remote server into a string. The code is as follows: if( !($fd = @fopen($ftp_url, "r")) ){ $error = true; $error_msg = "Unable to connect to server."; } else { $file_contents = fread($fd, 100000); fclose($fd); } if( empty($file_contents) ){ $error = true; $error_msg = "Did not read file."; } The problem is that the fread doesn't always succeed; about about half the time the $file_contents string tests as empty. There is never a problem with the fopen, and there doesn't seem to be any consistancy in the failure... The same file may be loaded into the string on run one, and missing the next. The remote server is NT-based. Does anybody know what is going wrong here? I don't have to add any logic to "wait" for the fread to complete, do I? Thanks, mth.

« previous php.general (#41046) next »