Welcome Guest, Not a member yet? Register   Sign In
Safari/quicktime not recognising mp3s piped through CI
#1

[eluser]pwninja[/eluser]
Code:
function do_download()
    {
        ob_end_clean();
        if(file_exists($this->fpath) && $fh = fopen($this->fpath, "rb")){
            $bufsize = 20000;            
            header("Accept-Ranges: bytes");
            header("Content-Length: ".filesize($this->fpath));
            header("Content-Type: ".$this->mimetypes[pathinfo($this->fpath,PATHINFO_EXTENSION)]); // "audio/mpeg"
            while($buf = fread($fh, $bufsize))
            {
                echo $buf;
            }    
            fclose($fh);
            
            $this->load->model('File_model');
            $this->File_model->increment_downloads($this->uri->segment(2), $this->uri->segment(3));
        }
        else
        {
           header("HTTP/1.0 404 Not Found");
           show_404($this->uri->segment(3));
           exit();
        }
    }

I'm using the above to pipe files through PHP/CI and it works fine on all browsers bar Safari. It only causes problems with media files such as mp3s and avis, the quicktime plugin in Safari tries to take over the handling of the file and ends up giving an error (the annoyingly un-verbose question mark over a quicktime logo). I've tried the exact same code minus the CI specific stuff in raw PHP and it works fine, I've also tried cleaning the output buffer directly before and compared the returned headers, which were identical.




Theme © iAndrew 2016 - Forum software by © MyBB