这篇文章主要介绍了php 点击链接图片下载程序代码 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
页面用<a href>click</a>跳转进来,就可以直接下载文件了
<br/>
$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);
The above is the detailed content of php click link image download program code. For more information, please follow other related articles on the PHP Chinese website!