Tuesday, November 1, 2011

PHP, compress and extract files using PclZip library


PclZip library offers PHP compression and extraction functions for Zip formatted archives. PclZip library can be downloaded from:
http://old.phpconcept.net/pclzip/index.en.php

The user menu can be found HERE.

To include pclzip library:
 include_once('pclzip.lib.php');
To add or extract very large file, "memory_limit" value in php.ini needs to be increased. "memory_limit" can also set in the PHP code:
 ini_set('memory_limit''180M');
To initialize a zip instance:
 $myzipfile = new PclZip('myzfile.zip');
To create a zip file from image1.jpg and image2.jpg:
$mylist $archive->create('mydata/image1.jpg,mydata/image2.jpg',
                             
PCLZIP_OPT_REMOVE_PATH'data',
                             
PCLZIP_OPT_ADD_TEMP_FILE_ON);

No comments:

Post a Comment