How to create a .zip in PHP script
How to create a .zip in PHP script:
<?php
$export_dir = "/inetpub/wwwroot/Jargon_WCG/download/TLD/";
$db_file = "WCG2_FF.odb";
$db_path = $export_dir . $db_file;
$zip_file = "WCG2_FF.zip";
$zip_path = $export_dir . $zip_file;
if (is_file($zip_path))
unlink($zip_path); // remove any old zip file not yet downloaded
$zip = new ZipArchive;
$res = $zip->open($zip_path, ZIPARCHIVE::CREATE);
if ($res === TRUE) {
$zip->addFile($db_path, $db_file);
$zip->close();
unlink($db_path); // remove the DB file itself, leaving the ZIP file
}
?>