PHP ReadFile function _php Tutorial

Source: Internet
Author: User
Tags readfile
PHP ReadFile functions

ReadFile
(PHP 4, PHP 5)

ReadFile-Output a file

Describe
International ReadFile (string $ file name [, Boolean $ use_include_path = False [, resource $ background]])
Reads the file and writes it to its output buffer.

Parameters

Filename
The file is read.

Use_include_path
You can use the optional second parameter set to TRUE if you want to search for the file in the Include_path also.

Background
Background flow resource.


return value
The number of bytes returned to read the file. If an error occurs, false, unless the returned function is called @ ReadFile (), the error message is printed.

Instance

For example # 1 forced download using ReadFile ()

$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
}
?>


http://www.bkjia.com/PHPjc/445475.html www.bkjia.com true http://www.bkjia.com/PHPjc/445475.html techarticle php readfile function ReadFile (PHP 4, PHP 5) ReadFile-Output A file description of international ReadFile (string $ file name [, Boolean $ use_include_path = False [, resource $ background. ..

  • Related Article

    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.