PHP Classes

Creating a zip with large file dynamically

Recommend this page to a friend!

      Zip  >  All threads  >  Creating a zip with large file...  >  (Un) Subscribe thread alerts  
Subject:Creating a zip with large file...
Summary:Unable to create a zip file with large file in memory.
Messages:9
Author:Priyam Chokhani
Date:2016-05-19 11:24:06
 

 


  1. Creating a zip with large file...   Reply   Report abuse  
Picture of Priyam Chokhani Priyam Chokhani - 2016-05-19 11:24:06
When trying to add a large file to a zip I get the following error-

PHP Warning: unpack(): Type V: not enough input, need 4, have 0 in Zip.php on line 454

PHP Warning: unpack(): Type V: not enough input, need 4, have 0 in Zip.php on line 456

This happens on only one of my machines. It works fine on other machines. The code is as follows -

$zip->addLargeFile($fileLocation,getFileName("abc"));

  2. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2016-05-19 11:42:55 - In reply to message 1 from Priyam Chokhani
What are the php versions and machine architecture (cpu &32/64 bit) on those machines. It sounds like a problem specific to either the PHP version, and/or the machine architecture.

  3. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Priyam Chokhani Priyam Chokhani - 2016-05-19 12:32:55 - In reply to message 2 from Asbjorn Grandt
The machine details are as follows -

Microsoft Windows Server 2012 Standard (x64- based processor)
PHP version - 5.6.0

The application is hosted on IIS.

  4. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2016-05-19 13:07:21 - In reply to message 3 from Priyam Chokhani
So, similar hardware an setup, but different results.

How large is the file you are trying to add? Zip in its current form does not support Zip64, meaning 4GB is the max, but due to bugs/design errors in PHP I think it might be limited to 2GB files.

  5. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Priyam Chokhani Priyam Chokhani - 2016-05-19 15:28:45 - In reply to message 4 from Asbjorn Grandt
The file size is around 5 MB. If I try adding small file (in KB's) using addFile, it works fine.

  6. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2016-05-19 16:30:35 - In reply to message 5 from Priyam Chokhani
The file should not fail. It really shouldn't. That version of Zip is getting quite old though, and it has been merged with the ZipStream package, which has been updated.

That said, it wouldn't matter really, as that part of the code is pretty much the same. For some reason the file handle of the temporarily zipped data is running out of data, something that shouldn't happen even if $fileLocation,getFileName("abc") returns something wrong.

Please check that $fileLocation,getFileName("abc") returns a valid file path, and that Zip is allowed to actually read it.

is_readable($fileLocation,getFileName("abc")) should return true if it's ok.


  7. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Priyam Chokhani Priyam Chokhani - 2016-05-20 08:32:39 - In reply to message 6 from Asbjorn Grandt
is_readable($fileLocation) gives true however the mentioned is_readable($fileLocation,getFileName("abc")) returns false as is_readable expects only 1 param.


Some more details - IIS 8 is being used, fast_cgi impersonation is enabled. We have given rights to IUSR which would be used for impersonation.

  8. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2016-05-20 10:36:55 - In reply to message 7 from Priyam Chokhani
Ah, I missed the comma, it looked like a dot. Sorry.

I'm trying to figure out what different is between the machines, you mentioned one worked, while the other didn't.

  9. Re: Creating a zip with large file...   Reply   Report abuse  
Picture of Priyam Chokhani Priyam Chokhani - 2016-05-20 11:06:23 - In reply to message 8 from Asbjorn Grandt
The machine on which it worked did not have fast_cgi impersonation enabled. I could only see this as a difference.