note 108022 deleted from ziparchive.addemptydir by danbrown

From: Date: Thu, 10 May 2012 17:57:16 +0000
Subject: note 108022 deleted from ziparchive.addemptydir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187691@lists.php.net to get a copy of this message
Note Submitter: pong_pc2 at hotmail dot com ---- Shouldn't it be this one. I've try Dayjo's and D.Jann's but neither of that works. So I've change something and it's working. <?php // Function to recursively add a directory, // sub-directories and files to a zip archive function addFolderToZip($dir, $zipArchive, $zipdir = ''){ if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory if(!empty($zipdir)) $zipArchive->addEmptyDir($zipdir); // Loop through all the files while (($file = readdir($dh)) !== false) { //If it's a folder, run the function again! if(!is_file($dir . "/" . $file)){ // Skip parent and root directories if( ($file !== ".") && ($file !== "..")){ addFolderToZip($dir . "/" . $file, $zipArchive, $zipdir . $file . "/"); } }else{ // Add the files $zipArchive->addFile($dir . "/" . $file, $zipdir . $file); } } } } } ?>

« previous php.notes (#187691) next »