Home  >  Article  >  Backend Development  >  PHP file download function_PHP tutorial

PHP file download function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:47:251117browse

This is html code. This is mainly used for PHP to download the content of this site. Put the file to be downloaded and the PHP code page in the same directory. I hope it can help more people. If you have any questions, you can also contact QQ: 523132661, waiting for your visit at any time. Happy work.

Broadband Troubleshooting Manual Download

The following is the word.php page

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('Broadband User Troubleshooting Manual.doc','GB2312','UTF-8')); // For IE

}else{

header("Content-Disposition: attachment; filename=".mb_convert_encoding('Broadband User Troubleshooting Manual.doc','GB2312','UTF-8')); // For Other browsers

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

echo fread($fp,1024);

} www.2cto.com

//@fpassthru($fp);

exit();

} else{

print "This file does not exist";

}

Excerpted from Spring’s column

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478511.htmlTechArticleThis is the html code. This is mainly used for PHP to download the content of this site. Put the file to be downloaded and the PHP code The page is placed in the same directory, hoping to help more people. If you have any questions...
Statement:
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