note 47924 deleted from ref.zip by danbrown
| From: | danbrown@php.net | Date: | Sun, 25 Oct 2009 13:14:48 +0000 |
| Subject: | note 47924 deleted from ref.zip by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162068@lists.php.net to get a copy of this message | ||
Note Submitter: kristiankjaer AT gmail DOT com
----
Here is a function if all you need is to unpack an archive:
function unpackZip($dir,$file) {
$root=$_SERVER['DOCUMENT_ROOT'];
if ($zip = zip_open($root.$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));
$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;
}