Create zip file of a folder

2

I have a folder named Photos, how do I create a photos.zip file with all the photos in it?

    
asked by anonymous 17.06.2016 / 16:29

1 answer

6

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.

    
17.06.2016 / 17:04