Yngvarr

Generation

generate functionSat, 07 Jan 2023

pack to gz and return archive file download

function pack($dir){ $dir = realpath($dir); $phar = new PharData($dir.'.tar'); $phar->buildFromDirectory($dir); $phar->compress(Phar::GZ); header('Content-Type: application/x-gzip'); header('Content-Disposition: attachment; filename="'.pathinfo($dir.'.tar.gz', PATHINFO_BASENAME).'"'); echo file_get_contents($dir.'.tar.gz'); }

Questions about programming?Chat with your personal AI assistant