note 98619 added to function.ziparchive-addemptydir
| From: | hunter666 at abv dot bg | Date: | Sat, 26 Jun 2010 20:38:04 +0000 |
| Subject: | note 98619 added to function.ziparchive-addemptydir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170492@lists.php.net to get a copy of this message | ||
Add folder and sub-directories to zip archive.
<?php
$archive_name = "archive.zip"; //
меÑÑонаÑ
ождениеÑо и имеÑо
на zip Ñайла
$archive_folder = "folder"; // папкаÑа, коÑÑо Ñе
бÑде аÑÑ
ивиÑана
$zip = new ZipArchive;
if ($zip -> open($archive_name, ZipArchive::CREATE) === TRUE)
{
$dir = preg_replace('/[\/]{2,}/', '/', $archive_folder."/");
$dirs = array($dir);
while (count($dirs))
{
$dir = current($dirs);
$zip -> addEmptyDir($dir);
$dh = opendir($dir);
while($file = readdir($dh))
{
if ($file != '.' && $file != '..')
{
if (is_file($file))
$zip -> addFile($dir.$file, $dir.$file);
elseif (is_dir($file))
$dirs[] = $dir.$file."/";
}
}
closedir($dh);
array_shift($dirs);
}
$zip -> close();
echo 'Archiving is sucessful!';
}
else
{
echo 'Error, can't create a zip file!';
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 85.130.90.65
----
Manual Page -- http://www.php.net/manual/en/function.ziparchive-addemptydir.php
Edit -- https://master.php.net/note/edit/98619
Del: integrated -- https://master.php.net/note/delete/98619/integrated
Del: useless -- https://master.php.net/note/delete/98619/useless
Del: bad code -- https://master.php.net/note/delete/98619/bad+code
Del: spam -- https://master.php.net/note/delete/98619/spam
Del: non-english -- https://master.php.net/note/delete/98619/non-english
Del: in docs -- https://master.php.net/note/delete/98619/in+docs
Del: other reasons-- https://master.php.net/note/delete/98619
Reject -- https://master.php.net/note/reject/98619
Search -- https://master.php.net/manage/user-notes.php