In the PHP program, you need to use PHP to do the file download
Just do it. Copy the code and change it.
There's a lot of effects coming out.
Then click on the download, um, I thought the file download, who knows, the picture opened when the prompt file corruption, which I observed the size of the file. It seems to be a lot of about 1KB.
Use PS to open, well, prompted the damage, but the image can come out.
Then I think it's the more 1kb problem.
Then, I upload a txt and then download it.
Sure enough, there were a few more characters in front and behind the file.
Then I was wondering how to get rid of it. Various Baidu, Google, on the forum to ask questions.
Finally, after my one-hour search, I finally found a solution.
The code is as follows
Public function Download () { $upload =m (' upload '); $data = $upload->find ($_get[' id "); if (empty ($data)) { header (' http/1.0 404 Not Found '); Header (' Location:. '); } else{ $path = './public/uploads/'. $data [' Savename ']; Header ("Content-type:". $data [' Type ']); Header (' content-disposition:attachment; filename= '. $data [' name ']. ' "'); Header (' Content-length: '. $data [' size ']); Ob_clean (); Flush (); ReadFile ($path); }}
Attention:
Ob_clean (); flush ();
This is the key. With these two functions, done, the picture is open normally, the text is not garbled.
Reprinted from: Http://www.9958.pw/post/download_content