0

Regards,

Using CodeIgniter-PHP and I have a Link (Download Audio) which makes the call to my controller that has the function of downloading audio in. Wav. As parameter I send the corresponding filename.

Here is my code on my controller:

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);
    }

When I click the link I download the wav audio properly, but when I try to play the audio I get that "The file corrupt" - "It needs a special codec"

What is it I'm doing wrong in my code?

Thanks in advance.

4

0 回答 0