evai

只需要在php文件中设置请求头就可以了,创建download.php文件,代码如下:

$fileName = $_GET[\'filename\']; //得到文件名
header( "Content-Disposition:  attachment;  filename=".$fileName); //告诉浏览器通过附件形式来处理文件
header(\'Content-Length: \' . filesize($fileName)); //下载文件大小
readfile($fileName);  //读取文件内容

html 代码如下:

<a href="download.php?filename=a.jpg">下载a.jpg</a>

 

分类:

技术点:

相关文章: