Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpack/extract zip file with PHP without relying on any extension

Tags:

php

zip

unzip

Is there any way to unpack or extract a zip file with PHP that does not rely on any installed extension? Has anyone written a class or something that can handle it?

Alternatively, is there a solution that uses an extension that is relatively commonly installed on most servers?

I need this to work on as many different servers that I have no control over as possible.

Thanks for any help!

like image 301
seventeen Avatar asked Dec 17 '09 16:12

seventeen


1 Answers

Check this lib it helps to solve same problem

require_once('pclzip.lib.php');

$archive = new PclZip(dirname(__FILE__).'/Archive.zip');

if ($archive->extract(PCLZIP_OPT_PATH, dirname(__FILE__).'/extract') == 0) {
    echo "\n error while extract";
} else {
    echo "\n extract ok";
}
like image 124
duganets Avatar answered Nov 05 '22 05:11

duganets