Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?
$path = "./";
$filename = "somefile.doc";
$fInfo = pathinfo($filename);
$type = $fInfo['extension'];
$disps = array("attachment", "inline");
switch ($type) {
case "exe": $ctype="application/octet-stream"; $disp = $disps[0];
break;
case "pdf": $ctype="application/pdf"; $disp = $disps[1];
break;
case "zip": $ctype="application/zip" ; $disp = $disps[0];
break;
case "doc": $ctype="application/msword"; $disp = $disps[1];
break;
case "xls": $ctype="application/vnd.ms-excel"; $disp = $disps[1];
break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; $disp = $disps[1];
break;
case "gif": $ctype="image/gif"; $disp = $disps[1];
break;
case "png": $ctype="image/png"; $disp = $disps[1];
break;
case "jpe": case "jpeg": case "jpg": $ctype="image/jpg"; $disp = $disps[1];
break;
default: $ctype="application/octet-stream"; $disp = $disps[0;]
}
//EXIST FILE? YES ->FORCEDOWNLOAD
// NO ->DIE AND COME BACK IF IS POSSIBLE
if (file_exists($path.$file)) {
header("Pragma: public");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $ctype");
header('Content-Disposition: '.$disp.'; filename="'.$filename.'.'.$type.'"');
header("Content-Transfer-Encoding: binary");
header('Content-Length: '.filesize($path.$file));
set_time_limit(0);
@readfile($path.$file) or die("Cannot read file for output");
exit;
} else {
die ("File does not exist at that path");
}
?>