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
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";
}
?>

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


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.