Home > php教程 > php手册 > PHP做文件下载功能

PHP做文件下载功能

WBOY
Release: 2016-06-13 10:46:14
Original
1300 people have browsed it

 

这个是html代码   这个主要是做PHP下载本站内容的功能,把要下载的文件和PHP代码页面放到同一目录下,希望能帮到更多的人,如有什么疑问,还可以联系QQ:523132661,随时等候你的大驾光临。祝工作愉快。  

 

宽带故障排查手册下载 

 

下面是word.php页面

 

if (!isset(GET["file"]) || !isset(GET["type"])) {  

print "no file selsect"; exit(); 

$file = GET["file"].".".GET["type"]; 

if (@$fp = fopen($file,'r')){ 

 header ("Content-type: octet/stream"); 

 if (strstr(SERVER["HTTP_USER_AGENT"], "MSIE")){ 

 header("Content-Disposition: filename=".mb_convert_encoding('宽带用户故障诊断处理手册.doc','GB2312','UTF-8')); // For IE 

 }else{ 

 header("Content-Disposition: attachment; filename=".mb_convert_encoding('宽带用户故障诊断处理手册.doc','GB2312','UTF-8')); // For Other browsers  

} while(!@feof($fp)){ 

 echo fread($fp,1024);  

}   www.2cto.com

//@fpassthru($fp); 

 exit();  

} else{ 

 print "此文件不存在"; 

 

摘自 Spring的专栏

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