Create a new zip file in ZipArchive.

Creating a new zip file in ZipArchive.

 
 

Share on Google+Share on Google+

Create a new zip file in ZipArchive.

Ads

Creating a new zip file in ZipArchive.

Creating a new Zip file in ZipArchive

For creating zip file, use zipArchive () class. Create a new zip file in ZipArchive. Use the conditional statement to add a file in the ZipArcive class. If the file exists, the create() function will generate a new zip file, in case of failure, it will print failed in creating zip file.

<?php
$newzip = new ZipArchive;
$create = $zip->open(’file.zip’, ZipArchive::CREATE);
if ($create=== TRUE) {
$newzip->addFile(’file.txt’,'file.txt');
$newzip->close();
echo "Zip file successfully created";
} else {
echo "Failed in creating zip file";
}
?>

Advertisements

Posted on: July 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles