您的位置:首页 > 编程语言 > PHP开发

读取大文件 php

2013-11-18 17:52 127 查看
ob_end_clean();
set_time_limit(0);
ob_start();
$filename = basename($path);
$suffix = self::extension($filename);

header('Content-Type:'类型' );
header('Content-Disposition: attachment; filename=' . $filename);

//读取超大文件
$handle = fopen($path,'rb');
if( $handle )
{
flock($handle,LOCK_SH);
while(!feof($handle)){
$buffer = fread($handle,1024*1024);
echo $buffer;
ob_flush();
flush();
}
flock($handle,LOCK_UN);
fclose($handle);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: