当前位置: 代码迷 >> PHP >> php怎么使用header直接下载图片
  详细解决方案

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

热度:75   发布时间:2016-04-29 00:44:41.0
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是真相.
  相关解决方案