1、页面中 下载连接
<a href="__URL__/down?file=D:\ABC&type=zip">下载文件</a>
2、控制器中down方法
public function down(){
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=ABC.jpeg".mb_convert_encoding('ABC.zip','GB2312','UTF-8')); // For IE
}else{
header("Content-Disposition: attachment; filename=".mb_convert_encoding('ABC.zip','GB2312','UTF-8')); // For Other browsers
} while(!@feof($fp)){
echo fread($fp,1024);
}
exit();
} else{
print "此文件不存在";
}
}