ftp_fget()返回传输完成错误

时间:2013-12-31 09:05:48

标签: php ftp

我正在尝试从远程FTP服务器下载图像并将其上传到我们自己的rackspace帐户。这适用于大约3000张图像,但随后它崩溃并给我以下错误:

  消息'ftp_fget()的

异常:转移完成。'

我们已尝试更改代码以使用ftp_get(),不使用临时文件存储它,但它总是导致相同的错误。它总是在相同的文件上失败,如果我要删除已经下载的几个文件并再次运行脚本,下载它们没有问题......一旦它到达FTP服务器上的那些特定图像就会再次失败。我已经尝试从服务器手动下载这些图像并且它工作,它们似乎没有任何问题。

这基本上就是代码:

$this->handle = ftp_connect($ftpurl);
$loggedIn = ftp_login($this->handle, $ftpusername, $ftppassword);
if ($loggedIn === false) {
    throw new Exception('Can\'t login to FTP server');
}
if ($this->handle === false) {
    throw new Exception('Could not connect to the given url');
}
ftp_pasv($this->handle, true);

$fileList = ftp_nlist($this->handle, '.');
if (count($fileList) === 0) {
    throw new Exception('No files found on FTP-server');
}

foreach($fileList as $filename) { 
    try {
        $container->getObject($filename);
        // Image already exists, rackspace has no convenient hasImage() function
    } catch (Exception $ex) {     
        $temp = tmpfile();
        ftp_fget($this->handle, $temp, $filename, FTP_BINARY);

        //upload $tmp to rackspace
    }
}

任何想法可能是什么问题?

0 个答案:

没有答案
相关问题