读取大文件 php
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); }
困难是老天给我们提高的机会,坚定不移勇敢地去攻克,不要退缩,加油!
posted on 2013-11-18 17:52 天地一连线_孤鸿挂飘渺 阅读(165) 评论(0) 编辑 收藏 举报