警告错误:ftp_get():传输完成.在cakeHP中


Warning Error: ftp_get(): Transfer complete. in cakePHP

我正试图从服务器下载一个zip文件并保存它。我收到以下错误。该项目在cakeHP 中

Downloading /server/biruhxml20140925.zip ... 
Warning Error: ftp_get(): Transfer complete. in [(pathprefix)/app/Console/Command/Task/ImportUtilityTask.php, line 214]
//server/biruhxml20140925.zip could not be downloaded to (pathprefix)/files/downloaded_files/bild/biruhxml20140925.zip
biruhxml20140925.zip could not be downloaded as the file is not there yet.

这是进行调用的函数。

public function downloadFTPFile ($remoteFile, $localFile) {
    $connection = $this->ftpConnection;
    ftp_pasv($this->ftpConnection, true);
    $this->out(__('Downloading %s ... ', $remoteFile));
    try {
        if (ftp_get($connection, $localFile, $remoteFile, FTP_BINARY)) {
            $this->out(__('Saved %s', $localFile));
            return true;
        } else {
            $this->out(__('%s could not be downloaded to %s', $remoteFile, $localFile));
            return false;
        }
    } catch (Exception $e) {
        @unlink($localFile);
        $this->out($e->getMessage());
    }
    $this->nl();
    return false;
}

除了在core.php 中设置调试级别0之外,有人能建议解决方案来消除警告吗

您是否考虑过,根据错误消息,您尝试下载的文件不在服务器上?

你的代码不会检查文件是否在那里,我会添加它并相应地处理这种情况。