Help With Headers

I’ve got this list of files, and certain ones are only accessible to certain users. I’ve got a script to handle sending them the files, and it works well enough. This is the part that generates the headers and sends the file:

[PHP] header(‘Content-Description: File Transfer’);
header(“Content-Type: " . $mm_type);
header('Content-Disposition: attachment; filename=”’.basename($path).’"’);
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header("Content-Length: " .(string)(filesize($path)) );

readfile($path);
exit;[/PHP]It works, but it works differently than the other links in that it automatically causes the file to be downloaded, whereas my other directly linked files usually open up in the browser without being downloaded.

Is there a way I can edit the headers to make sure that the special files are opened in the same way?

header('Content-Description: File Transfer');

Pretty sure this is what causes it to force the download.

That’s what I thought at first too, but I looked it up and it actually has no bearing on the function of the script at all. It’s kind of the header version of a comment, just there for people to look at and know what the programmer’s intention was. Taking it out doesn’t do anything.

What kind of file types are they?

They are mp3 files - should have mentioned that up front, I’ll edit the original post.

EDIT - Why am I allowed to modify this one but not my original post?

Yeah, that changes things a bit. For sound files, you need to embed them in the html so they don’t get served as downloadable files.

Using HTML5: http://www.w3schools.com/tags/ref_av_dom.asp
Reference: http://www.w3schools.com/html/html_media.asp

The thing is, I want to put these files into an RSS feed.

Sponsor our Newsletter | Privacy Policy | Terms of Service