note 48142 deleted from ref.zip by danbrown

From: Date: Sun, 25 Oct 2009 13:14:38 +0000
Subject: note 48142 deleted from ref.zip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162067@lists.php.net to get a copy of this message
Note Submitter: schore at NOSPAM dot hotmail dot com ---- I have had problems with the function of kristiankjaer to unpack zipfiles within any directories. So I wrote a little extension. <?php function unpackZip($dir,$file) { if ($zip = zip_open($dir.$file.".zip")) { if ($zip) { mkdir($dir.$file); while ($zip_entry = zip_read($zip)) { if (zip_entry_open($zip,$zip_entry,"r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); $dir_name = dirname(zip_entry_name($zip_entry)); if ($dir_name != ".") { $dir_op = $dir.$file."/"; foreach ( explode("/",$dir_name) as $k) { $dir_op = $dir_op . $k; if (is_file($dir_op)) unlink($dir_op); if (!is_dir($dir_op)) mkdir($dir_op); $dir_op = $dir_op . "/" ; } } $fp=fopen($dir.$file."/".zip_entry_name($zip_entry),"w"); fwrite($fp,$buf); zip_entry_close($zip_entry); } else return false; } zip_close($zip); } } else return false; return true; } ?>

« previous php.notes (#162067) next »