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

  $local_file = '';
  $archive = new PclZip('');
  if ($archive->extract(PCLZIP_OPT_PATH, 'raw_data') == 0) {
    die("Error : ".$archive->errorInfo(true));


I tried another class - It only creates a zero-length file.

I also tried direct unix unzip execution as


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?


Who is Participating?
If you are using exec('unzip ...') the php-script will first continue if unzip has finished. To get the returncode of unzip see 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
andy7789Author Commented:
so, i will keep the exec() solution and stop looking for some other classes - thank you
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.