Simple Zip Archive Given Folder And Download Using PHP On Linux Server
May 9, 2019 5:45 am by
ATS Staff
<?php
// zip
$file = $_GET['folder'];
exec("zip -r $file.zip $file");
// download
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename("$file.zip").'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize("$file.zip"));
flush(); // Flush system output buffer
readfile("$file.zip");
// clean
exec("rm $file.zip");
?>