WC_Download_Handler::readfile_chunked PHP Méthode

readfile_chunked() public static méthode

Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/.
public static readfile_chunked ( string $file ) : boolean
$file string
Résultat boolean Success or fail
    public static function readfile_chunked($file)
    {
        $chunksize = 1024 * 1024;
        $handle = @fopen($file, 'r');
        if (false === $handle) {
            return false;
        }
        while (!@feof($handle)) {
            echo @fread($handle, $chunksize);
            if (ob_get_length()) {
                ob_flush();
                flush();
            }
        }
        return @fclose($handle);
    }

Usage Example

/**
 * @deprecated
 */
function woocommerce_readfile_chunked($file, $retbytes = true)
{
    _deprecated_function('woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()');
    return WC_Download_Handler::readfile_chunked($file);
}