php代码img.php
<?php
$filename = "2.jpg";
header('Content-Type:image/gif');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length:'.filesize($filename));
readfile($filename);
?>
<a href="img.jpg" id="" >1</a>
新开窗口打开
<a href="img.jpg" target="_blank" id="" >1</a>
<a href="img.php" target="_blank" id="" >1</a>//把上面php代码设置content-disposition那行去掉
新开窗口下载
<a href="img.php" target="_blank" id="" >1</a>
新开窗口下载的另外一种方法参见上一篇文章。