note 70462 added to ref.zip
| From: | bholub at chiefprojects dot com | Date: | Tue, 17 Oct 2006 19:14:26 +0000 |
| Subject: | note 70462 added to ref.zip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118664@lists.php.net to get a copy of this message | ||
This will simply unpack (including directories) $zip to $dir -- in this example the zip is being
uploaded.
<?php
$dir = 'C:\\reports-temp\\';
$zip = zip_open($_FILES['report_zip']['tmp_name']);
while($zip_entry = zip_read($zip)) {
$entry = zip_entry_open($zip,$zip_entry);
$filename = zip_entry_name($zip_entry);
$target_dir = $dir.substr($filename,0,strrpos($filename,'/'));
$filesize = zip_entry_filesize($zip_entry);
if (is_dir($target_dir) || mkdir($target_dir)) {
if ($filesize > 0) {
$contents = zip_entry_read($zip_entry, $filesize);
file_put_contents($dir.$filename,$contents);
}
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 65.200.4.130
----
Manual Page -- http://www.php.net/manual/en/ref.zip.php
Edit -- https://master.php.net/note/edit/70462
Del: integrated -- https://master.php.net/note/delete/70462/integrated
Del: useless -- https://master.php.net/note/delete/70462/useless
Del: bad code -- https://master.php.net/note/delete/70462/bad+code
Del: spam -- https://master.php.net/note/delete/70462/spam
Del: non-english -- https://master.php.net/note/delete/70462/non-english
Del: in docs -- https://master.php.net/note/delete/70462/in+docs
Del: other reasons-- https://master.php.net/note/delete/70462
Reject -- https://master.php.net/note/reject/70462
Search -- https://master.php.net/manage/user-notes.php