Readfile
(PHP 4 and PHP 5)
Readfile-output a file
Description
International readfile (string $ file name [, Boolean $ use_include_path = false [, resource $ background])
Read the file and write it to the output buffer.
Parameters
File name
The file is read.
Use_include_path
You can use the optional second parameter to set it to TRUE. If you want to search the include_path file.
Background
Background stream resource.
Return value
The number of bytes returned to read the file. If an error occurs, it is false unless the returned function is @ readfile (). The error message is printed.
Instance
For example, #1 force download using readfile ()
<? Php
$ File = 'monkey.gif ';
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 ();
Flush ();
Readfile ($ file );
Exit;
}
?>