
March 25th, 2008, 09:11 AM
|
 |
Web Developer/Musician
|
|
Join Date: Nov 2004
Location: Lincoln Nebraska
|
|
Try the following
PHP Code:
Original
- PHP Code |
|
|
|
function getMimeType($file) { $ext = $nameArr[(count($nameArr) - 1)]; { case 'pdf': $type = 'application/pdf'; break; case 'jpg': $type = 'image/jpeg'; break; case 'jpeg': $type = 'image/jpeg'; break; case 'gif': $type = 'image/gif'; break; case 'mp4': $type = 'application/mpeg4-generic'; break; case 'mp3': $type = 'audio/mpeg'; break; case 'tiff': $type = 'image/tiff'; break; case 'png': $type = 'image/png'; break; case 'csv': $type = 'text/csv'; break; case 'txt': $type = 'text/plain'; break; case 'xml': $type = 'text/xml'; break; case 'html': $type = 'text/html'; break; case 'doc': $type = 'application/msword'; break; case 'zip': $type = 'application/zip'; break; case 'jpeg2000': $type = 'image/jp2'; break; case 'rtf': $type = 'text/rtf'; break; case 'mov': $type = 'video/quicktime'; break; case 'xls': $type = 'application/excel'; break; case 'ppt': $type = 'application/powerpoint'; break; case 'wav': $type = 'audio/x-wav'; break; case 'aiff': $type = 'audio/aiff'; break; case 'mid': $type = 'audio/x-midi'; break; case 'bmp': $type = 'image/bmp'; break; case 'mpeg': $type = 'video/mpeg'; break; case 'mpg': $type = 'video/mpeg'; break; case 'avi': $type = 'x-msvideo'; break; case 'pub': $type = 'application/x-mspublisher'; break; case 'sit': $type = 'application/x-stuffit'; break; case 'tar': $type = 'application/x-tar'; break; case 'ra': $type = 'audio/x-pn-realaudio'; break; case 'ram': $type = 'audio/x-pn-realaudio'; break; case 'tsv': $type = 'text/tab-separated-values'; break; case 'asf': $type = 'video/x-ms-asf'; break; case 'wma': $type = 'audio/x-ms-wma'; break; case 'wmv': $type = 'video/x-ms-wmv'; break; case 'flv': $type = 'video/x-flv'; break; case 'swf': $type = 'application/x-shockwave-flash'; break; case 'fla': $type = 'application/octet-stream'; break; default: $type = 'application/octet-stream'; break; } return $type; } function downloadHeaders($file,$filelen,$mode='I') { // $mode: D = force download, I = attempt inline $type = getMimeType($file); { } header('Cache-Control: max-age=0'); header("Cache-Control: private", false); // required for certain browsers header('Content-Type: '. $type); if($mode == 'D') { header('Content-Disposition: attachment; filename='. $file); } else { header('Content-Disposition: inline; filename='. $file); }
|