Home >Backend Development >PHP Tutorial >PHP file download function_PHP tutorial
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