读书人

php怎么使用header直接下载图片

发布时间: 2012-07-19 16:02:19 作者: rapoo

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

[解决办法]
1,打header
2, 输出图片

不会? php manual : gd
[解决办法]
搜索 Content-Disposition HTTP

PHP code
<?php// We'll be outputting a PNG imageheader('Content-type: image/png');// It will be called hello.pngheader('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是真相.

读书人网 >PHP

热点推荐