PHP download instructions & lt ;? Php?file="=koala.jpg & quot; if (file_exists ($ file) {header ('content-Description: FileTransfer '); // What is corresponding to the content description? the header is not clear ('cont PHP download instructions
$ File = "Koala.jpg ";
If (file_exists ($ file )){
Header ('content-Description: File Transfer '); // What is the corresponding Content Description?
Header ('content-Type: application/octet-stream'); // file Type, in eight bytes
Header ('content-Disposition: attachment; filename = '. basename ($ file); // download a file named $ file in the current directory.
Header ('content-Transfer-Encoding: binary '); // Some Encoding
Header ('expires: 0'); // not quite understandable
Header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0'); // Cache Control, you must authenticate again. I understand it as the confirmation button in the download.
Header ('pragma: public ');
Header ('content-Length: '. filesize ($ file); // Content Length
Ob_clean ();
Flush ();
Readfile ($ file );
Exit ();
}
?>
This is a successful download code on the internet. I have tested it.
However, the void header provided in the manual (string [, bool replace [, int http_response_code])
I guess the general meaning of the code.
Is the above header the information in the pop-up download prompt box? I hope some experts can give me some details.
------ Solution --------------------
You only need to download the following items:
PHP code
$file = 'ASDFGgg.pdf';_Download("files_dir/".$file, $file);function _Download($f_location,$f_name){ header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($f_location)); header('Content-Disposition: attachment; filename=' . basename($f_name)); readfile($f_location); }