note 52310 added to ref.zip

From: Date: Wed, 27 Apr 2005 15:52:37 +0000
Subject: note 52310 added to ref.zip
Groups: php.notes 
Request: Send a blank email to php-notes+get-88640@lists.php.net to get a copy of this message
New Unzip function, recursive extract Require mkdirr() (recursive create dir) $file = "2537c61ef7f47fc3ae919da08bcc1911.zip"; $dir = getcwd(); function Unzip($dir, $file, $destiny="") { $dir .= DIRECTORY_SEPARATOR; $path_file = $dir . $file; $zip = zip_open($path_file); $_tmp = array(); $count=0; if ($zip) { while ($zip_entry = zip_read($zip)) { $_tmp[$count]["filename"] = zip_entry_name($zip_entry); $_tmp[$count]["stored_filename"] = zip_entry_name($zip_entry); $_tmp[$count]["size"] = zip_entry_filesize($zip_entry); $_tmp[$count]["compressed_size"] = zip_entry_compressedsize($zip_entry); $_tmp[$count]["mtime"] = ""; $_tmp[$count]["comment"] = ""; $_tmp[$count]["folder"] = dirname(zip_entry_name($zip_entry)); $_tmp[$count]["index"] = $count; $_tmp[$count]["status"] = "ok"; $_tmp[$count]["method"] = zip_entry_compressionmethod($zip_entry); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); if($destiny) { $path_file = str_replace("/",DIRECTORY_SEPARATOR, $destiny . zip_entry_name($zip_entry)); } else { $path_file = str_replace("/",DIRECTORY_SEPARATOR, $dir . zip_entry_name($zip_entry)); } $new_dir = dirname($path_file); // Create Recursive Directory mkdirr($new_dir); $fp = fopen($dir . zip_entry_name($zip_entry), "w"); fwrite($fp, $buf); fclose($fp); zip_entry_close($zip_entry); } echo "\n</pre>"; $count++; } zip_close($zip); } } Unzip($dir,$file); ---- Manual Page -- http://www.php.net/manual/en/ref.zip.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52310 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52310&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52310&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52310&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52310&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52310&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52310&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88640) next »