Created
July 8, 2013 04:08
-
-
Save anonymous/5946181 to your computer and use it in GitHub Desktop.
PHP Script to zip folder. It can be used on shared webhosts where the zip functionality is not enabled. From http://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path="../ctest"; | |
$zip = new ZipArchive; | |
$zip->open('../ctest.zip', ZipArchive::CREATE); | |
if (false !== ($dir = opendir($path))) { | |
while (false !== ($file = readdir($dir))) { | |
if ($file != '.' && $file != '..') { | |
$zip->addFile($path.DIRECTORY_SEPARATOR.$file); | |
//delete if need | |
//if($file!=='important.txt') | |
//unlink($path.DIRECTORY_SEPARATOR.$file); | |
} | |
} | |
} | |
else { | |
die('Can\'t read dir'); | |
} | |
$zip->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment