Home > php教程 > PHP源码 > php下载程序

php下载程序

PHP中文网
Release: 2016-05-25 17:10:56
Original
1470 people have browsed it

php下载程序

<?php 
 
$path = &#39;1.rar&#39;; 
 
$extension = getFileExt($f); 
 
switch ($extension){ 
case "jpg": 
case "jpeg": $ctype="image/jpeg"; break; 
case "pdf": $ctype="application/pdf"; break; 
case "gif": $ctype="image/gif"; break; 
case "png": $ctype="image/png"; break; 
case "doc": $ctype="application/msword"; break; 
case "zip": $ctype="application/zip";break; 
case "rar": $ctype="application/rar"; break;   
default: $ctype="application/force-download"; 
} 
 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: private",false); 
header("Content-type: ". $ctype); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ". filesize($path)); 
header(&#39;Content-Disposition: attachment; filename="100.jpg" ;&#39;); 
 
readfile(   $path  ); 
function getFileExt($file_name){   
$extend = explode("." , $file_name);   
$type = $extend[count($extend)-1]; 
return strtolower($type);   
}   
?>
Copy after login


                   

 以上就是php下载程序的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template