0) { header('Content-Length:' . (($end - $begin) + 1)); if (isset($_SERVER['HTTP_RANGE'])) { header("Content-Range: bytes $begin-$end/$size"); } } header("Content-Transfer-Encoding: binary"); //Squashes headers() warning on PHP 5.3/ubuntu 12.04: flush(); //We can have multiple levels of output buffering. Need to //keep looping until all have been disabled!!! //http://www.php.net/manual/en/function.ob-end-flush.php while (ob_get_level() > 0) { ob_end_flush(); } // NOTE: We can't use fseek here because it does not work with streams // (a.k.a. Files stored in the cloud) while(!feof($fm) && (connection_status() == 0)) { echo fread($fm, 1024 * 8); } fclose($fm); } }