Current File : /home/inlingua/www/noida/icentex/tutorials_documents_download.php |
<?php
include("check.php");
include("connection.php");
//mysqli_connect($SERVER,$USERNAME, $PASSWORD);
//mysqli_select_db($DATABASE);
$dof="formsandtotorials/".$_REQUEST['file']."";
$file_extension = strtolower(substr(strrchr($_REQUEST['file'],"."),1));
switch( $file_extension )
{
case "csv": $ctype="application/force-download";break;
case "csv": $ctype="application/octet-stream";break;
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 "pptx": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
//default: echo "<html><title>This file cannot be downloaded</title> <body>ERROR: This file cannot be downloaded</body></html>";exit;
}//End condition switch( $file_extension )
header('Content-Description: File Transfer');
header('Content-Type: '.$ctype.'');
header('Content-Disposition: attachment; filename='.$_REQUEST["file"].'');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($dof));
ob_clean();
flush();
readfile($dof);
exit;
?>