音频文件.wav使用php下载后损坏

时间:2012-11-16 05:26:01

标签: codeigniter audio download

此致

使用CodeIgniter-PHP,我有一个链接(下载音频),它调用我的控制器,具有下载音频的功能.Wav。 作为参数,我发送相应的文件名。

这是我的控制器上的代码:

public function downloadFile($filename) {
        $filepath = base_url().'audiofiles/'.$filename;
        $filesize = filesize($filepath);
        header('Content-Description: File Transfer');
        header('Pragma: public');
        header('Expires: 0');
        header("Content-Type: application/force-download"); 
        header('Content-Type: application/octet-stream');
        header("Content-Type: application/download");
        header("Content-Length: ".$filesize);
        header("Content-disposition: attachment; filename=$filename");
        header('Content-Transfer-Encoding: binary');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        readfile($filepath);
    }

当我点击链接时,我正确地下载了wav音频,但当我尝试播放音频时,我得到了“文件损坏” - “它需要一个特殊的编解码器”

我的代码中有什么问题?

提前致谢。

0 个答案:

没有答案