I have a folder named Photos, how do I create a photos.zip file with all the photos in it?
I have a folder named Photos, how do I create a photos.zip file with all the photos in it?
According to the response from SOEN
$zipFile = "./testZip.zip";
$zipArchive = new ZipArchive();
if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE))
die("Failed to create archive\n");
$zipArchive->addGlob("./*.txt");
if (!$zipArchive->status == ZIPARCHIVE::ER_OK)
echo "falha ao criar o zip\n";
$zipArchive->close();
In the example above, all .txt
files of the specified directory will be added in the zip.