When doing the picture download station, often needs to give the user to download the picture, but the picture browser can open directly. How to do, there is no way to let the picture type of file pop download box download it, phperz.com
Of course there is, PHP's header function can provide this method PHP Programmer's Home
The following code you can copy down to test the type of www.phperz.com
The following is the referenced content:
<?php
$filename = "123.jpg";//Picture address, can be absolute address or relative address
Header ("Content-type:application/force-download");
Header (' content-disposition:attachment; Filename= '. $filename. ');
$img = file_get_contents ($filename);
Echo $img;
?> |
Www.phperz.com
The effect is as follows: www.phperz.com
Www.phperz.com
The key point is that the PHP Programmer's Home
Header ("Content-type:application/force-download");
Header (' content-disposition:attachment; Filename= '. $filename. ');
Phperz~com
This two lines of code lets tell the browser to force the download of the file
Reprint to: Phpzer
"Go" php to let the picture pop-up Download box method