note 65947 deleted from ref.zip by danbrown

From: Date: Wed, 29 Jun 2011 15:26:34 +0000
Subject: note 65947 deleted from ref.zip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181048@lists.php.net to get a copy of this message
Note Submitter: ---- I try to use the function unpackZip from schore at NOSPAM dot hotmail dot com. it appears that the fclose instruction is missing. Without that instruction, i've got some trouble to unpack zip file with recursive folders. Here is the new code with the missing instruction <?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); fclose($fp); zip_entry_close($zip_entry); } else return false; } zip_close($zip); } } else return false; return true; } ?>

« previous php.notes (#181048) next »