Home Tutorial Php Examples Create a new zip file in ZipArchive.

 
 

Create a new zip file in ZipArchive.
Posted on: July 30, 2009 at 12:00 AM
Advertisement
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";
}
?>

Advertisement

Related Tags for Create a new zip file in ZipArchive.:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com