PHP by modifying the header to force the image download method,
This example describes how PHP enforces the download of images by modifying the header. Share to everyone for your reference. The implementation method is as follows:
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 is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/972638.html www.bkjia.com true http://www.bkjia.com/PHPjc/972638.html techarticle PHP by modifying the header to force the image download method, this article describes the PHP by modifying the header to force the image download method. Share to everyone for your reference. The concrete implementation method is as follows: ...