HTML
<a href="process.php?file=pic.jpg">Image goes Here</a>
PHP
<?php
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
改写 例:
laravel
HTML
<a href="{{url('qrcode/downImg')}}?file={{asset("$row->file_name")}}" class="DMP_ARYY DMP_XRYY" >下载 </a><span>|</span>
PHP控制器
//二维码列表展示中,下载二维码
public function downImg()
{
$input = Input::all();
$file = $input['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename="."aa.jpg".";");
//header("Content-Length: ".filesize($file));
readfile($file);
}
}