在我的託管服務提供商升級服務器(Debian)和PHP(從5.2.6到5.3.2)後,我在我們的網站上遇到了我的文件下載腳本問題。小則100MB的文件將下載好的,但較大的文件,然後將100MB的下載僅156個字節的文件......這是我的下載腳本:PHP強制下載 - 大於100MB的文件將只下載少量內容
class Download_Controller extends Website_Controller
{
public function index()
{
if (isset($_GET['file'])) {
$file = $_GET['file'];
$filORM = ORM::factory('file')->where('filename', $file)->find();
if ($filORM->loaded and $filORM->deleted=='N' and file_exists(APPPATH.'downloads/'.$file)) {
//we can serve file download
$this->auto_render = false;
$filORM->counter = $filORM->counter + 1;
$filORM->save();
$dl = ORM::factory('download');
$dl->download_file_id = $filORM->id;
$dl->created = time();
$dl->country_id = $this->country->id;
$dl->ip = $this->_getRealIpAddr();
$dl->browser = Kohana::user_agent('browser');
$dl->version = Kohana::user_agent('version');
$dl->platform = Kohana::user_agent('platform');
$dl->save();
return download::force(APPPATH.'downloads/'.$file);
}
else {
$this->download_error();
}
}
else {
//else here we load download center UI
$this->section();
}
}
}
我使用Kohana的PHP框架。版本2.3.x.
你有訪問服務器嗎?或者它是一個託管服務器? – Stony 2012-01-13 09:39:44
我有ssh訪問權限。 – 2012-01-13 09:40:56
這些156字節文件的內容是什麼?有什麼特別的? – Maerlyn 2012-01-13 09:43:27