页面用<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 点击链接图片下载程序代码 的详细内容,更多请关注php中文网其它相关文章!
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论