在我的托管服务提供商升级服务器(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