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

WBOY
Release: 2016-06-13 13:25:12
Original
1058 people have browsed it

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"');
<br /><font color="#e78608">------解决方案--------------------</font><br>
直接下载应该是用header跳到图片的网址上<br>例如图片的路径是http://test.com/pic/test1.jpg<br><br>要下载的话<br>header("Location:http://test.com/pic/test1.jpg")
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

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

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

------解决方案--------------------
不过楼主好像要的是下载-,- 我也没看清, #2是真相.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!