I'm trying to allow users to download files (PDF, PPT, etc.) from the web server using a PHP script -- i.e. rather than opening them in the browser window. The following works well for modern IE and Firefox browsers, but Netscape 7.x loads PDF files in the browser window rather than allowing user to download them:
if(file_exists('path/filename')) {
header("Content-type: $mimetype");
header("Content-length: $filesize");
header("Content-Disposition: attachment; filename=$filename");
readfile('path/filename');
}
On the other hand, if I specify the content-type as "application/octet-stream" -- as many posts advise -- this does get NS 7.x to allow the user to download the file, but it adds a .php extension to the end of the filename (specified by $filename variable in the script above) -- so filename.pdf becomes filename.pdf.php.
Anyone know how to get around this for NS users? I can't rely on endusers knowing that they can open the file by deleting the .php ending of the file name.