&1"); preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); $totalsize = $matches[1]; header("Content-Length: $totalsize"); } # final step : stream the directory content via tar header('Content-Type: application/x-tar'); header('Content-Disposition: attachment; filename="'.basename($realDir).'.tar"'); passthru("tar $TAR_FLAGS -c $filesarg"); ?>