I'm building a site for a friend where people can download his music. For security and logging purposes, I'm handling all file downloads through a php page and I'm ouputting the file when I'm done checking permissions and logging. Here's the code I'm using.
header('Content-Length: '.$clip->getFilesize());
header('Content-Type: '.$clip->getContentType());
header('Content-Disposition: attachment; filename="'.$clip->getFilename().'"');
@readfile($path);
Internet Explorer doesn't want to be a team player (as usual). Firefox, Opera and SeaMonkey are fine. I get a Save As... dialog, and I can either select Open or Save As..., and the file gets either opened in the appropriate application or saves to my hard drive with the name I output in the header. In IE, when I select "Save As..." it times out and says it can't find the file. It does, however, open the file if I select Open, but in both cases it uses the name of the page (download.php?id=...) instead of the filename I output in the header.
Anyone got some pointers on this issue, besides the obvious IE bashing?