Download Code
October 9th, 2007 Posted in PHP
This code is something i found that will force download, rather than opening in browser:
PHP:
-
<?php
-
$filename = $my_file_name;
-
$filename = "/". $filename;
-
}
-
-
-
-
if( $filename == "" ) {
-
};
-
switch( $file_extension ) {
-
case "pdf": $ctype="application/pdf"; break;
-
//case "exe": $ctype="application/octet-stream"; break;
-
case "zip": $ctype="application/zip"; break;
-
case "doc": $ctype="application/msword"; break;
-
case "xls": $ctype="application/vnd.ms-excel"; break;
-
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
-
case "gif": $ctype="image/gif"; break;
-
case "png": $ctype="image/png"; break;
-
case "js" : $ctype="application/x-javascript"; break;
-
case "jpeg":
-
case "jpg": $ctype="image/jpg"; break;
-
default: $ctype="application/force-download";
-
}
-
?>