Learn Something New Every Day

Every day, people learn something new that adds some kind of value to their lives. I am going to try to post at one thing that I learn every day. I am a law school graduate, used to do some IT work, and just generally get out and around, so this shouldn’t be too difficult to do, right? We’ll see…

How To Unzip/Extract Large Zip Files Using PHP Without the PECL Zip Library

If you’re on Dreamhost and you don’t want to mess with installing a clean install of PHP and then installing PECL’s Zip library, this may help…

I was able to handle several large (i.e., hundreds of megabytes) files using the pclzip library discussed here: http://stackoverflow.com/questions/1923100/unpack-extract-zip-file-with-php-without-relying-on-any-extension

Note: you have to set the location for the script to create a temporary file.  Look for the line where “PCLZIP_TEMPORARY_DIR” is defined and include a file system location that is writable by the script.

Here’s the web address for the script: http://www.phpconcept.net/pclzip/

It was as easy as: 

require_once('pclzip.lib.php');

$archive
= new PclZip('filename.zip');

if ($archive->extract() == 0) {
    echo
"\n error while extract";
}