php实现下载文件(浏览器不直接打开)
时间:2018-03-20 10:26:33
收藏:0
阅读:252
test.html:
<a href="do.php?ac=dw">下载12.jpg</a>
<a href="do.php?ac=dw">下载12.jpg</a>
do.php:
if($_GET[‘ac‘]==‘dw‘) {
$file = ‘./12.jpg‘; //文件路径
$filename = basename($file); //要下载文件的名字
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".($filename));
readfile($file);
}
原文:http://blog.51cto.com/12363916/2088854
评论(0)