php: extracting large files from zip archives

Hi X-perts,

I need to extract a large file (about 100mb a single file) from a zip archive. I have been trying PclZip class and it works fine on relatively small files - even for huge archives of 500mb. However it does not work for a single large file (no warnings, no messages whatsoever). Here is my current code with PclZip

<?php
  require_once('pclzip.lib.php');
  set_time_limit(600);
  $local_file = 'current_data_full.zip';
  $archive = new PclZip('current_data_full.zip');
  if ($archive->extract(PCLZIP_OPT_PATH, 'raw_data') == 0) {
    die("Error : ".$archive->errorInfo(true));
  }

?>

I tried another class - http://www.lost-in-code.com/2007/05/15/php-upload-extract-zip-archive/. It only creates a zero-length file.

I also tried direct unix unzip execution as

<?
exec('unzip cur.zip');
?>

This is the only code working for large files so far.

Please, advise some other zip classes working for huge files. I am using php 4.4.2

Another question, if I use exec('unzip ...'), it takes 5-10 sec to execute. How can I make sure that the file is fully extracted before continuing the script?

Thanks

A
andy7789Asked:
Who is Participating?
 
hernst42Commented:
If you are using exec('unzip ...') the php-script will first continue if unzip has finished. To get the returncode of unzip see http://www.php.net/exec. AFAIK there are no classes for php 4.x which can cope good with larg files. php 5.x has a native interface/streamwrapper for zip-files which does not require a lot of memory when working with files inside the zip. Upgrade to php5.2.x
0
 
andy7789Author Commented:
so, i will keep the exec() solution and stop looking for some other classes - thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.