下载图片php?

时间:2009-08-26 15:09:43

标签: php image download hyperlink

当你点击这个图像时我会如何制作你会开始下载它?

这是我的代码

            } elseif (isset($_REQUEST['animeinput']) && !empty($_REQUEST['animeinput'])) {

echo "<a href=\"sig.php?user=".$_REQUEST['user']."&anime=".substr($_REQUEST['animeinput'],0,32)."&color2=".$_REQUEST['color2']."\"><img type=\"image\" width=\"350\" height=\"100\" border=\"0\" src=\"sig.php?user=".$_REQUEST['user']."&anime=".substr($_REQUEST['animeinput'],0,32)."&color2=".$_REQUEST['color2']."\" /></a>";

2 个答案:

答案 0 :(得分:4)

要提示浏览器将请求视为下载,您的sig.php需要输出Content-Disposition标题,如下所示:

header('Content-Disposition: attachment; filename="suggested_filename.png"');

(我假设sig.php已经输出了所有其他必要的标题,如Content-Type等)

答案 1 :(得分:-1)

使用

header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$name.'"');

还会查看Content-encodingContent-length