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); }