I have found here at stackoveflow some codes on how to ZIP a specific file, but how about a specific folder?
Folder/
index.html
picture.jpg
important.tx
I did some small improvement in the script.
open($zip_name, ZipArchive::CREATE);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $file) {
$path = $file->getRealPath();
//check file permission
if(fileperms($path)!="16895"){
$zip->addFromString(basename($path), file_get_contents($path)) ;
echo "{$path} is added to zip file.
" ;
}
else{
echo"{$path} location could not be added to zip
";
}
}
$zip->close();
?>