I am having some trouble embedding (using <embed>) an audio or video file into Firefox when that video/audio file is fetched using a PHP script that sends headers and reads in the specificed file. I can embed video/audio using this method in IE just fine (using the <object> tag).
If I embed a file directly (without using the PHP script), it works just fine -- but I need to use the PHP script in this case.
This is my <embed> code:
(note: please do not address the fact the a user could grab a file from anywhere s/he pleases without proper security checks. I am making sure that any file fetched via this script is strictly validated against a hard-coded list and the GET variable stripped of any potentially-harmful characters)
<embed
type=\"application/x-mplayer2\"
src=\"/path/to/php/fetch/script?filename=$MyFilename\"
pluginspage=\"http://www.microsoft.com/windows/windowsmedia/default.mspx\">
</embed>
My fetcher script can be summarized as:
header("Content-Disposition: filename=\"$ParsedMyFilename\");
header("Content-Length: " . filesize($ParsedFilePath));
header("Content-Type: $ContentType");
readfile($ParsedFilePath);
(assume those variables are already calculated and set)
I have checked that the script is sending the correct MIME file type (it is). Am I missing some HTTP headers or something?