php readfile 函數
readfile
( PHP 4中, PHP 5中)
readfile -輸出一個檔案
描述
國際readfile (字串$檔案名稱[ ,布爾$ use_include_path =虛假[ ,資源$背景] ] )
讀取檔案並寫入它的輸出緩衝器。
參數
檔案名稱
該檔案被讀取。
use_include_path
您可以使用可選的第二個參數設定為TRUE ,如果你想搜尋該檔案中的include_path中也。
背景
背景流資源。
傳回值
返回的位元組數讀取檔案。如果出現錯誤,虛假,除非返回的功能稱為@ readfile ( ) ,錯誤資訊列印。
執行個體
例如# 1強迫下載使用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.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445475.htmlTechArticlephp readfile 函數 readfile ( PHP 4中, PHP 5中) readfile -輸出一個檔案 描述 國際readfile (字串$檔案名稱[ ,布爾$ use_include_path =虛假[ ,資源$背景...