Last active
June 6, 2018 10:57
-
-
Save npget/7055b7d125b4d8f6b56cba31616ed8fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function open_file_exp_doc($url){ | |
header('Content-Description:NpGet-Archistore-Files'); | |
header("Content-Type: ".$this->FileMtipe($url)); | |
header("Content-Disposition: inline; filename=".basename($url)); | |
header('Content-Transfer-Encoding: binary\n'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Pragma: public'); | |
ob_clean(); | |
flush(); | |
readfile($url); | |
} | |
public function FileMtipe($url){ | |
$ctype=null; | |
$ext=pathinfo($url, PATHINFO_EXTENSION); | |
switch ($ext) { | |
case "pdf": $ctype="application/pdf"; break; | |
case "exe": $ctype="application/octet-stream"; break; | |
case "zip": $ctype="application/zip"; break; | |
case "xml": $ctype="text/plain"; break; | |
case "txt": $ctype="text/plain"; break; | |
case "docx":$ctype="text/plain"; break; | |
case "doc": $ctype="text/plain"; break; | |
case "csv": $ctype="text/plain"; break; | |
case "sds": $ctype="text/plain"; break; | |
case "prn": $ctype="text/plain"; 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 "jpeg":$ctype="image/jpeg"; break; | |
case "jpg":$ctype="image/jpeg"; break; | |
//default: $ctype="application/force-download"; | |
} | |
return $ctype; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment