Create zip archive of a folder

Asked

Viewed 1,015 times

2

Guys I have a folder called Photos, how do I create a photo.zip archive with all the photos inside?

1 answer

6


According to the reply of 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 above example, all files .txt specific directory will be added in zip.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.