note 100802 added to function.ziparchive-extractto

From: Date: Mon, 08 Nov 2010 07:22:01 +0000
Subject: note 100802 added to function.ziparchive-extractto
Groups: php.notes 
Request: Send a blank email to php-notes+get-173840@lists.php.net to get a copy of this message
If you want to copy one file at a time and remove the folder name that is stored in the ZIP file, so you don't have to create directories from the ZIP itself, then use this snippet (basically collapses the ZIP file into one Folder). <?php $path = 'zipfile.zip' $zip = new ZipArchive; if ($zip->open($path) === true) { for($i = 0; $i < $zip->numFiles; $i++) { $filename = $zip->getNameIndex($i); $fileinfo = pathinfo($filename); copy("zip://".$path."#".$filename, "/your/new/destination/".$fileinfo['basename']); } $zip->close(); } ?> * On a side note, you can also use $_FILES['userfile']['tmp_name'] as the $path for an uploaded ZIP so you never have to move it or extract a uploaded zip file. Cheers! ProNeticas Dev Team ---- Server IP: 192.41.42.26 Probable Submitter: 71.109.100.213 ---- Manual Page -- http://www.php.net/manual/en/function.ziparchive-extractto.php Edit -- https://master.php.net/note/edit/100802 Del: integrated -- https://master.php.net/note/delete/100802/integrated Del: useless -- https://master.php.net/note/delete/100802/useless Del: bad code -- https://master.php.net/note/delete/100802/bad+code Del: spam -- https://master.php.net/note/delete/100802/spam Del: non-english -- https://master.php.net/note/delete/100802/non-english Del: in docs -- https://master.php.net/note/delete/100802/in+docs Del: other reasons-- https://master.php.net/note/delete/100802 Reject -- https://master.php.net/note/reject/100802 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173840) next »