This article mainly introduces the PHP by modifying the header mandatory image download method, example analysis of the PHP forced image download skills, with a certain reference value, the need for friends can refer to the
The example in this article describes the way that PHP modifies the header force picture download. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13-14 |
function DownloadFile ($file) {$file _name = $file; $mime = ' application/force-download '; header (' pragma:public ');//requ Ired header (' expires:0 '); No cache header (' Cache-control:must-revalidate, post-check=0, pre-check=0 '); Header (' Cache-control:private ', false); Header (' Content-type: '. $mime); Header (' Content-disposition:attachment filename= '. basename ($file _name); Header (' content-transfer-encoding:binary '); Header (' Connection:close '); ReadFile ($file _name); Push It out exit (); } |
I hope this article will help you with your PHP program design.