public function readfileChunked($filename, $retbytes = false)
    {
        $chunksize = 1 * (1024 * 1024); // how many bytes per chunk
        $buffer = '';
        $cnt = 0;
        $handle = fopen($filename, 'rb');
        if ($handle === false) {
            return false;
        }
        while (!feof($handle)) {
            $buffer = fread($handle, $chunksize);
            echo $buffer;
            ob_flush();
            flush();
            if ($retbytes) {
                $cnt += $this->binaryStrLen($buffer);
            }
        }
        $status = fclose($handle);
        if ($retbytes && $status) {
            return $cnt; // return num. bytes delivered like readfile() does.
        }
        return $status;
    }
public function readfileChunked($filename, $retbytes = false)
    {
        $chunksize = 1 * (1024 * 1024); // how many bytes per chunk
        $buffer = '';
        $cnt = 0;
        $handle = fopen($filename, 'rb');
        if ($handle === false) {
            return false;
        }
        while (!feof($handle)) {
            $buffer = fread($handle, $chunksize);
            echo $buffer;
            ob_flush();
            flush();
            if ($retbytes) {
                $cnt += $this->binaryStrLen($buffer);
            }
        }
        $status = fclose($handle);
        if ($retbytes && $status) {
            return $cnt; // return num. bytes delivered like readfile() does.
        }
        return $status;
    }
public function readfileChunked ( $ filename , $ retbytes = false ) { $ chunksize = 1 * ( 1024 * 1024 ) ; // how many bytes per chunk $ buffer = '' ; $ cnt = 0 ; $ handle = fopen ( $ filename , 'rb' ) ; if ( $ handle === false ) { return false ; } while ( ! feof ( $ handle ) ) { $ buffer = fread ( $ handle , $ chunksize ) ; echo $ buffer ; ob_flush ( ) ; flush ( ) ; if ( $ retbytes ) { $ cnt += $ this -> binaryStrLen ( $ buffer ) ; } } $ status = fclose ( $ handle ) ; if ( $ retbytes && $ status ) { return $ cnt ; // return num. bytes delivered like readfile() does. } return $ status ; }
send the content of a file to the output by chuncks in order to
limite the memory consumption.
@param $filename
@param $retbytes
@return stream of bytes by chunks of 1Mo
send the content of a file to the output by chuncks in order to limite the memory consumption .