note 69407 added to ref.zip
| From: | phpContrib | Date: | Tue, 05 Sep 2006 09:35:34 +0000 |
| Subject: | note 69407 added to ref.zip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116689@lists.php.net to get a copy of this message | ||
1) A warning to all users of PHP Zipping/Unzipping Classes: most of them require the whole content
of the ZIP file and/or the unzipped contents to stay in memory. They work very well, but might fail
with very large files. Keep this in mind before starting development of a project involving large
ZIP files.
2) If all you need is to unzip files to a folder, and your server has a zip command line tool, all
you might need is a function like this:
if(!defined('UNZIP_CMD')) define('UNZIP_CMD','unzip -o @_SRC_@ -x -d
@_DST_@');
function UnzipAllFiles($zipFile,$zipDir) {
$unzipCmd=UNZIP_CMD;
$unzipCmd=str_replace('@_SRC_@',$zipFile,$unzipCmd);
$unzipCmd=str_replace('@_DST_@',$zipDir,$unzipCmd);
$res=-1; // any nonzero value
$UnusedArrayResult=array();
$UnusedStringResult=exec($unzipCmd,$UnusedArrayResult,$res);
return ($res==0);
}
// * * * You DO NOT NEED the ZIP lib or M-ZIP to use this, but you will need the tool M-ZIP uses
(unzip.exe or unzip for linux). * * *
// Use it this way:
$zipFile='/path/to/uploaded_file.zip';
$whereToUnzip='/path/to/writable/folder/';
$result=UnzipAllFiles($zipFile,$whereToUnzip);
if($result===FALSE) echo('FAILED');
else echo('SUCCESS');
By changing UNZIP_CMD (the same constant as in the m-zip lib) you can
of course untar, unarc, unrar, etc... provided you have the correct
unwhatever command or unwhatever.exe executable and write its correct syntax in UNZIP_CMD.
To see details of what tools you need and where to put them (or to use a syntax compatible to the
standard zip lib) see http://eSurfers.com/m-zip/
----
Server IP: 66.163.161.117
Probable Submitter: 213.156.52.105
----
Manual Page -- http://www.php.net/manual/en/ref.zip.php
Edit -- https://master.php.net/note/edit/69407
Del: integrated -- https://master.php.net/note/delete/69407/integrated
Del: useless -- https://master.php.net/note/delete/69407/useless
Del: bad code -- https://master.php.net/note/delete/69407/bad+code
Del: spam -- https://master.php.net/note/delete/69407/spam
Del: non-english -- https://master.php.net/note/delete/69407/non-english
Del: in docs -- https://master.php.net/note/delete/69407/in+docs
Del: other reasons-- https://master.php.net/note/delete/69407
Reject -- https://master.php.net/note/reject/69407
Search -- https://master.php.net/manage/user-notes.php