// Today, I encountered a bug when writing a project. when I wrote the image downloading function, I clicked "download", but I couldn't read the image. I also tried a lot of methods and felt very depressed. Finally, I got my classmate's code into the exam and still couldn't use it. I was wondering how to use it in his place? Why can't I do this? I'm depressed for nearly 3... SyntaxHighlighter. all ();
// Today, I encountered a bug when writing a project. when I wrote the image downloading function, I clicked "download", but I couldn't read the image. I also tried a lot of methods and felt very depressed. Finally, I got my classmate's code into the exam and still couldn't use it. I was wondering how to use it in his place? Why can't I do this? I was depressed for nearly 30 minutes. Finally, he said that there was no data in front of the header. now I suddenly realized that I should clear the data and suddenly got a sigh of relief, this small problem has delayed nearly one lesson, so I want to share it with you to avoid making such a mistake.
The code is as follows:
/Upload path
[Html]
$ Filename = $ _ GET ["photo"];
// Clear the preceding information
Ob_clean ();
Header ("Content-Type: image/pjpeg ");
Header ("Content-Disposition: attachment; filename =". $ filename );
Header ("Content-Length:". filesize ($ filename ));
Readfile ($ filename );
From xweina's column