This article is the use of PHP implementation of the download file of the two methods for a detailed analysis of the introduction, the need for friends under the reference
Method One:
Copy Code code as follows:
header (' Content-description:file Transfer ');
header (' Content-type:application/octet-stream ');
header (' Content-disposition:attachment filename= '. basename ($filepath));
header (' content-transfer-encoding:binary ');
header (' expires:0′);
header (' Cache-control:must-revalidate, post-check=0, pre-check=0′);
header (' pragma:public ');
header (' content-length: '. FileSize ($filepath));
ReadFile ($file _path);
Method Two:
Copy Code code as follows:
$fileinfo = PathInfo ($filename);
header (' content-type:application/x-'. $fileinfo [' Extension ']);
header (' content-disposition:attachment; filename= '. $fileinfo [' basename ']);
header (' content-length: '. FileSize ($filename));
readfile ($thefile);
exit ();