note 65998 deleted from ref.zip by danbrown

From: Date: Sun, 25 Oct 2009 13:11:53 +0000
Subject: note 65998 deleted from ref.zip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162060@lists.php.net to get a copy of this message
Note Submitter: nospam at hostingfanatic dot com ---- I needed a quick way to make a zip file from an entire directory including subdirectories. This is downright rough but if someone would fancy it up a bit it works good with the zip class at http://smiledsoft.com/demos/phpzip/ (free version). Basic use in script would be... make_archive("the/directory", $zip_archive_object); <?php function make_archive( $dir , &$zip, $extdir="") { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false ) { if( $file != "." && $file != ".." ) { if( is_dir( $dir . $file ) ) { $zip->add_file($dir.$file,$extdir.$file); make_archive($dir.$file."/" , $zip, $extdir.$file."/"); } else { $zip->add_file($dir.$file,$extdir.$file); } } } closedir($dh); } } return true; } ?>

« previous php.notes (#162060) next »