All pastes #331224 Raw Edit

Mine

public text v1 · immutable
#331224 ·published 2007-01-28 17:57 UTC
rendered paste body

function readfile_chunked ($filename) {

        $chunksize = 1*(1024*1024); // how many bytes per chunk
        $chunksize = 8192;
        $buffer = '';
        $handle = fopen($filename, 'rb');
 
        if ($handle === false) {
                return false;
        }
        ob_end_clean();

        while (!feof($handle) && (connection_status() == 0)) {
                set_time_limit(0);
                $writefp = fopen("testout.txt", "a");
                fprintf($writefp, "1 ");
                fclose($writefp);

                $buffer = fread($handle, $chunksize);
                echo $buffer;
                ob_flush();
                flush();
        }
        return fclose($handle);
}

       if ($download != "") {
                $mimeType = image_type_to_mime_type(exif_imagetype("$picturesPath/$file"));
                header("content-type: $mimeType");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("content-disposition: attachment; filename=$file");
                header("Content-length: " . filesize("$picturesPath/$file"));
                header("Content-Transfer-Encoding: binary");

                readfile_chunked("$picturesPath/$file");

                exit;           
        }