PHP download instructions

Source: Internet
Author: User
PHP download instructions & lt ;? Php?file=&quot=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);  }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.