Link to home
Start Free TrialLog in
Avatar of andy7789
andy7789

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andy7789
andy7789

ASKER

so, i will keep the exec() solution and stop looking for some other classes - thank you