MakeZip
<?php
$rootPath = realpath(getcwd());
$zip = new ZipArchive();
$zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
if (!$file->isDir() )
{
$filePath = $file->getRealPath();
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
$file = basename($filePath);
if ($ext != "zip" AND $file != "make-zip.php")
{
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
}
$zip->close();
header("Location: file.zip");
die();
?>