php实现下载文件(浏览器不直接打开)
更新:HHH   时间:2023-1-7


test.html:
<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);

}

返回web开发教程...