读取大文件 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);
        }
困难是老天给我们提高的机会,坚定不移勇敢地去攻克,不要退缩,加油!
原文地址:https://www.cnblogs.com/merlini/p/3429926.html