Maison  >  Article  >  développement back-end  >  PHP做文件下载功能_PHP教程

PHP做文件下载功能_PHP教程

WBOY
WBOYoriginal
2016-07-13 17:47:251087parcourir

 

这个是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的专栏

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478511.htmlTechArticle这个是html代码 这个主要是做PHP下载本站内容的功能,把要下载的文件和PHP代码页面放到同一目录下,希望能帮到更多的人,如有什么疑问...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn