Yngvarr

Generation

generate functionSat, 07 Jan 2023

gzencode and stream http archive

function gzip_and_stream_archive($archive_file_path) { if (file_exists($archive_file_path)) { if (function_exists('gzencode')) { $archive_size = filesize($archive_file_path); $fp = fopen($archive_file_path, 'r'); if ($fp) { // send gzipped archive header("Content-Encoding: gzip"); header("Content-Length: " . $archive_size); header("Content-Disposition: attachment; filename=backup.tar.gz"); print(gzencode(fread($fp, $archive_size))); fclose($fp); unlink($archive_file_path); return true; } } else { // send unencoded archive header("Content-Type: application/x-gzip"); header("Content-Length: " . filesize($archive_file_path)); header("

Questions about programming?Chat with your personal AI assistant