日期:2014-05-17  浏览次数:20489 次

php如何使用header直接下载图片?
不是压缩包,而是图片格式直接下载,如jpg、png格式图片用header函数直接下载,求解

------解决方案--------------------
1,打header
2, 输出图片

不会? php manual : gd
------解决方案--------------------
搜索 Content-Disposition HTTP
PHP code
<?php
// We'll be outputting a PNG image
header('Content-type: image/png');
// It will be called hello.png
header('Content-Disposition: attachment; filename="hello.png"');

------解决方案--------------------
直接下载应该是用header跳到图片的网址上
例如图片的路径是http://test.com/pic/test1.jpg

要下载的话
header("Location:http://test.com/pic/test1.jpg")
------解决方案--------------------
探讨

直接下载应该是用header跳到图片的网址上
例如图片的路径是http://test.com/pic/test1.jpg

要下载的话
header("Location:http://test.com/pic/test1.jpg")

------解决方案--------------------
不过楼主好像要的是下载-,- 我也没看清, #2是真相.