一、函数介绍:
- 该函数读入一个文件并写入到输出缓冲,成功返回TRUE、失败返回FALSE
- readfile(filename,include_path,context)
二、代码实例:
$file_name = 'http://www.xxx.com/a/b/c'
header ( 'Content-Description: File Transfer' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Disposition: attachment; filename=' . $file_name . '.pdf'); #可自定义文件名
header ( 'Content-Transfer-Encoding: binary' );
header ( 'Expires: 0' );
header ( 'Cache-Control: must-revalidate' );
header ( 'Pragma: public' );
header ( 'Content-Length: ' . filesize ( $file_name ));
ob_clean ();
flush ();
readfile ( $file_name ); exit;