0

ユーザーがmp3ファイルをダウンロードできる小さなWebサイトを開発しています。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;
        }
    }

ダウンロード リンクの URL はhttp://yourdomain.com/download/63の形式で、63 はアイテム ID です。デスクトップからリンクをクリックすると、エラーなしでファイルがダウンロードされます。しかし、スマートフォン(Android)から同じリンクをクリックすると、次のエラーが表示されます

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

一部のモバイルから、ダウンロードされますが、ファイルを開くことができません。誰が私がどこで間違っているのか知っていますか?

4

0 に答える 0