note 65998 added to ref.zip

From: Date: Thu, 11 May 2006 17:27:34 +0000
Subject: note 65998 added to ref.zip
Groups: php.notes 
Request: Send a blank email to php-notes+get-111144@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 70.56.25.31 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.zip.php Edit -- http://master.php.net/note/edit/65998 Del: integrated -- http://master.php.net/note/delete/65998/integrated Del: useless -- http://master.php.net/note/delete/65998/useless Del: bad code -- http://master.php.net/note/delete/65998/bad+code Del: spam -- http://master.php.net/note/delete/65998/spam Del: non-english -- http://master.php.net/note/delete/65998/non-english Del: in docs -- http://master.php.net/note/delete/65998/in+docs Del: other reasons-- http://master.php.net/note/delete/65998 Reject -- http://master.php.net/note/reject/65998 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111144) next »