PHP download Find a way to solve the problem

Source: Internet
Author: User
PHP download to find guidance
$file = "Koala.jpg";

if (file_exists ($file)) {
Header (' Content-description:file Transfer ');//should be a description of what is not clear
Header (' Content-type:application/octet-stream '); File type, eight-bit byte stream
Header (' content-disposition:attachment; Filename= '. basename ($file)); Download a file with the file name $file in the current directory
Header (' content-transfer-encoding:binary '); Some kind of code.
Header (' expires:0 '); Don't quite understand
Header (' Cache-control:must-revalidate, post-check=0, pre-check=0 '); Cache control, must be re-certified I understand that's the OK 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 that I've been playing online I've already tested it.

But due to the void header provided above the manual (string string [, bool replace [, int http_response_code]])
Not too detailed, so I guess the general meaning of the code


Is the header above the message that pops up the download prompt? I hope to have a master can give some detailed

------Solution--------------------
Download as long as there are a few major items you can:
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.