filesize远程FTP文件会返回0长度,使用strlen代替(ticket #85)

This commit is contained in:
wlx 2009-05-19 04:14:26 +00:00
parent b23a994e13
commit 5d865362f8
1 changed files with 3 additions and 2 deletions

View File

@ -580,9 +580,10 @@ class DataController extends Zend_Controller_Action
{ {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$content=file_get_contents($url);
$this->getResponse()->setHeader('Content-Type', 'application/octet-stream') $this->getResponse()->setHeader('Content-Type', 'application/octet-stream')
->setHeader('Content-Disposition','attachment; filename="'.basename($url).'"') ->setHeader('Content-Disposition','attachment; filename="'.basename($url).'"')
->setHeader('Content-Length', filesize($url)) ->setHeader('Content-Length', strlen($content))
->setHeader('Content-Type','application/force-download') ->setHeader('Content-Type','application/force-download')
->setHeader('Content-Type','application/download') ->setHeader('Content-Type','application/download')
->setHeader('Content-Description','File Transfer') ->setHeader('Content-Description','File Transfer')
@ -590,7 +591,7 @@ class DataController extends Zend_Controller_Action
->setHeader('Expires',0) ->setHeader('Expires',0)
->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
->setHeader('Pragma','public') ->setHeader('Pragma','public')
->setBody(file_get_contents($url)); ->setBody($content);
} else { } else {
//是一个FTP返回用户名称和密码说明 //是一个FTP返回用户名称和密码说明
if ($p['host']=='ftp.westgis.ac.cn') if ($p['host']=='ftp.westgis.ac.cn')