Home > php教程 > php手册 > body text

写php下载图片时遇到的bug

WBOY
Release: 2016-06-13 10:48:42
Original
929 people have browsed it

//今天写项目时遇到了个bug,写下载图片功能时点击下载就是读不出图片,路径也对试了好多方法都不对,感觉很郁闷。最后把我同学的代码考上了还是不能用,我就在想在他那怎么能用?我这怎么就不行呢,郁闷了将近30分钟最后他说header前面不能有数据吧,这时我豁然开朗是啊,应该清空下的,顿时出了口气,这么小的问题耽误了将近一节课,因此我要把它分享给大家不要再犯这样的错误了

代码如下:

/上传路径


[html]
$filename=$_GET["photo"]; 
//清空以上信息 
 ob_clean(); 
header("Content-Type:image/pjpeg"); 
header("Content-Disposition:attachment;filename=".$filename); 
header("Content-Length:".filesize($filename)); 
readfile($filename);  


摘自 席伟娜的专栏
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 Recommendations
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!