我正在尝试从服务器下载zip文件并保存。我收到以下错误。 该项目在cakePHP
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
答案 0 :(得分:1)
您是否根据错误消息考虑了您尝试下载的文件在服务器上不存在?
您的代码不会检查文件是否存在,我会添加并相应地处理该情况。