PHP下载脚本在从移动设备打开时显示错误

时间:2013-08-03 05:38:50

标签: php codeigniter

我正在开发一个小网站,用户可以在其中下载mp3文件。用PHP和PHP编写的下载脚本Codeigniter是

public function index($id)
    {

        $item = $this->music_m->get($id);
        if(count($item)){
            $path = $item->upload_path;

            if (file_exists($path)) {
                $item->noOfDownloads = $item->noOfDownloads + 1;
                $this->music_m->save($item, $id);
                header('Content-Description: File Transfer');
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename='.basename($path));
                header('Content-Transfer-Encoding: binary');
                header('Expires: 0');
                header('Cache-Control: must-revalidate');
                header('Pragma: public');
                header('Content-Length: ' . filesize($path));
                ob_clean();
                flush();
                readfile($path);        
                exit;
            }else{
                echo "File doesnot exist";
                exit;
            }
        }else{
            echo "Requested music item doesn't exist in database";
            exit;
        }
    }

下载链接的网址格式为http://yourdomain.com/download/63,其中63为商品ID。 现在,当我从桌面单击链接时,它将下载文件而不会出现任何错误。但是,当我从智能手机(Android)点击相同的链接时,它给了我以下错误

ob_clean(): failed to delete buffer, no buffer to delete.

从某些手机上下载,但无法打开文件。谁知道我做错了什么?

0 个答案:

没有答案