note 110513 added to ziparchive.addfile
| From: | DeanRather | Date: | Wed, 31 Oct 2012 03:47:52 +0000 |
| Subject: | note 110513 added to ziparchive.addfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191610@lists.php.net to get a copy of this message | ||
This add directory function does not require that you create a new wrapper class, and also does not
add the entire file directory tree into your zip file.
<?php
public function addDirectoryToZip($zip, $dir, $base)
{
$newFolder = str_replace($base, '', $dir);
$zip->addEmptyDir($newFolder);
foreach(glob($dir . '/*') as $file)
{
if(is_dir($file))
{
$zip = $this->addDirectoryToZip($zip, $file, $base);
}
else
{
$newFile = str_replace($base, '', $file);
$zip->addFile($file, $newFile);
}
}
return $zip;
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 59.167.240.84
----
Manual Page -- http://www.php.net/manual/en/ziparchive.addfile.php
Edit -- https://master.php.net/note/edit/110513
Del: integrated -- https://master.php.net/note/delete/110513/integrated
Del: useless -- https://master.php.net/note/delete/110513/useless
Del: bad code -- https://master.php.net/note/delete/110513/bad+code
Del: spam -- https://master.php.net/note/delete/110513/spam
Del: non-english -- https://master.php.net/note/delete/110513/non-english
Del: in docs -- https://master.php.net/note/delete/110513/in+docs
Del: other reasons-- https://master.php.net/note/delete/110513
Reject -- https://master.php.net/note/reject/110513
Search -- https://master.php.net/manage/user-notes.php