Php code & lt ;? Php $ fileget_file_address (); // the actual address of the file (url is supported, but url is not recommended) if (file_exists ($ file) {header (& amp; #39; content-Description: FileTransfer & amp; #39;); header (& amp; #39;
Php code
$ File = get_file_address (); // the actual address of the file (url is supported, but url is not recommended)
If (file_exists ($ file ))
{
Header ('content-Description: File Transfer ');
Header ('content-Type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = '. basename ($ file ));
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 ($ file ));
Ob_clean (); // call this function. clear the file but do not disable the output cache. Otherwise, the first two characters of the downloaded file will be 0a.
Flush ();
Readfile ($ file); // output file content
}
?>
----------------------- EOF ------------------------
This article is from the "pswzyu technical blog"