时间:2021-07-01 10:21:17 帮助过:41人阅读
页面用<a href>click</a>跳转进来,就可以直接下载文件了
$imageName = $_GET['imageName'];
$imageUrl = $_GET['imageUrl'];
$localhostPath = str_replace("\\","/",dirname(__FILE__)); //这里要引用绝对路径
$imageUrl = $localhostPath."/".$imageUrl."/".$imageName; //合并成一个完整的路径
$imageUrl = iconv('utf-8', 'gbk', $imageUrl); //这里可以防止中文名文件乱码,我的机器环境是utf-8
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header("Content-Length:". filesize($imageName));
ob_clean();
flush();
readfile($imageUrl);以上就是php 点击链接图片下载程序代码 的详细内容,更多请关注Gxl网其它相关文章!