This script has been bugging me for a long time. It works perfectly in mozilla/netscape, but in IE it has a bug. The user clicks on the link ../download.php?file_name=path_to_file.doc. The bug in IE is that it thinks the file_name is "download.php" instead of "path_to_file"... It will download the proper file, but it saves it as "download.php"... What is the trick to getting IE to get the value of $file_name?
$filetype = substr($data[$file_name],strlen(trim($data[$file_name]))-3,3);
switch( $filetype ){
case "doc" : $filemime ="application/doc"; break;
case "xls": $filemime ="application/xls"; break;
case "pdf": $filemime ="application/pdf"; break;
default : $filemime ="application/force-download"; break;
}
header('Content-type: $filemime');
header("Content-Disposition: attachment; filename=$file_name");
readfile($file_name);