PHP CODE:$FTPServer="192.168.0.1";
$FTPAccount="root";
$FTPPassword="root";// define some variables
$ftpconn = ftp_connect($FTPServer);
$login_result = ftp_login($ftpconn, $FTPAccount, $FTPPassword);// check connection
if ((!$ftpconn) || (!$login_result)) {
    die("FTP connection has failed !");
}// get contents of the root directory
$contents = ftp_nlist($ftpconn, "/");// print each entry
if(!empty($contents))
{
foreach ($contents as $entry)
{
$local_file = "/tmp/".$entry;
$server_file = $entry;
if (ftp_get($ftpconn, $local_file, $server_file, FTP_BINARY)) 
{
                   echo "Download File successfully!\n";
                }else {
   echo "Download File err!\n";
}
        }
}FTP目录下存放的都是一些txt文件,文件中的字符量在100个以内。我现在遇到的问题是下载单个文件没问题,但是一旦FTP目录下的文件超过100个,需要花费几十秒下载的话,php就会在某一个位置报错,每次运行脚本,什么时候出现错误的时间不确定,有的时候是下载30多个文件就报错,有的时候下载100多个文件才报错。错误信息如下:
PHP Warning:  ftp_get(): Opening BINARY mode data connection for 20110526102925046.txt (72 Bytes). in /var/www/html/home/Crontab/ftp.php on line 24
Download File err!
PHP Warning:  ftp_get(): Cannot open data connection. in /var/www/html/home/Crontab/ftp.php on line 24
Download File err!
PHP Warning:  ftp_get(): PORT Command successful. in /var/www/html/home/Crontab/ftp.php on line 24
Download File err!我是在LINUX下执行这个PHP脚本的
执行命令是php /var/www/html/home/Crontab/ftp.php