Bugs encountered when writing php to download images_PHP tutorial

WBOY
Release: 2016-07-13 17:50:21
Original
687 people have browsed it

//I encountered a bug when I was writing a project today. When I was writing the function of downloading pictures, I couldn’t read the picture when I clicked the download button. The path was correct and I tried many methods but nothing was right. I felt very depressed. In the end, my classmate's code passed the test but it still didn't work. I was wondering how it could be used in his place? Why can't I do this? I was depressed for nearly 30 minutes. Finally, he said that there can't be data in front of the header. At this time, it suddenly dawned on me that yes, it should be cleared. I let out a sigh of relief. Such a small problem delayed nearly a class. , so I want to share it with everyone so that you don’t make such mistakes again

The code is as follows:

/upload path


[html]
$filename=$_GET["photo"];
//Clear the above information
ob_clean();
header("Content-Type:image/pjpeg");
header("Content-Disposition:attachment;filename=".$filename);
header("Content-Length:".filesize($filename));
readfile($filename);


Excerpted from Xi Weina’s column

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478283.htmlTechArticle//I encountered a bug when writing a project today. When writing the download image function, I clicked the download button and the image could not be read. I also tried many methods to get the path right, but nothing worked, which made me feel very depressed. Finally, my classmate’s representative...
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