- Code: Select all
$objZip = new ZipArchive( );
$sZipFile = "demo.zip";
if ($objZip->open($sZipFile, ZIPARCHIVE::CREATE) === TRUE)
{
$objZip->addFile("/path/file-a.ext", "file-a.ext");
$objZip->addFile("/path/file-b.ext", "file-b.ext");
$objZip->close( );
}
First of all, we are creating a new zip archive using the code
- Code: Select all
$objZip = new ZipArchive( );
$objZip->open($sZipFile, ZIPARCHIVE::CREATE);
Then we have to add files into the archive using the addFile function.
- Code: Select all
$objZip->addFile("/path/file-a.ext", "file-a.ext");
And in the end, we are closing the zip archive creation process.
- Code: Select all
$objZip->close( );