[eluser]Matt Larsen[/eluser]
Hey,
I'm trying to create an "embed file" script. For example:
Code:
<embed src="http://mysite.com/embed/1"></embed>
The script works perfectly for images. One of the files i'm testing is an MP3. This file type doesn't seem to work. I've executed the URL, and I get a download dialog. I've assumed this to be the problem. When I execute the URL with the image file type, I simply get the image (no download dialog).
Here's my code:
Code:
function embed($file_id = 0)
{
$file = $this->files->get($file_id);
if($file)
{
$mime = $this->mimes->get($file['ext']); //mp3's are: audio/mpeg3. I've double checked that this mime actually gets used as the header.
if(!$mime) {
$mime['mime'] = 'application/octet-stream';
}
header('Content-type: ' . $mime['mime']);
header('Content-disposition: inline; filename="' . $file['name'] . '.' . $file['ext'] . '"');
header('Accept-Ranges: bytes');
header('Content-Length: ' . filesize('./files/' . $file['filename']));
header('Keep-Alive: timeout=5, max=100');
header('Connection: Keep-Alive, Keep-Alive');
readfile(base_url() . 'files/' . $file['filename']);
}
}
Are there any other headers I should include? Or is there a header I need to change? Thanks very much for your time,
Matt