Skip to content
Advertisement

Unable to unzip large Linux zipped archive in Windows

Server environment:

  • Linux RHEL5 x86_64, Apache, PHP

Client environment:

  • Windows 10 64 bit (VirtualBox MacOS host), 4GB Ram, 30GB free space, Browser IE11 (also tested with Edge/Firefox), 7zip

The scenario is the following:

  • I upload a zip (there is a file inside the archive that is 2.5GB) via browser to my PHP web server, SHA2 checksum match when the zip arrived on server side
  • I unpack the zip on the server, generates an XML file based on the files inside, then add the XML file back into the original zip. eg: $xml->addFromString("hello.xml", $xmldata);
  • I then close the zip and let the user download the zip file.

The problem is that when I try to open the downloaded zip, the xml I added is “missing”, 7zip reported that there are data after the payload. If I unpack the exact same zip on the server side, everything is in there… If I scp the zip to my local machine, then transfer over to my Windows machine, and opens it there, it is fine too…

Which lead me to think, the header I’m setting might be wrong… I’ve tried various different ways, but still couldn’t resolve it… here is the latest header that I have…

JavaScript

I also tried with application/zip, that doesn’t work either.

Update:

So if I download the zip file via browser (IE11) the file’s checksum is different than the zip generated on the server… If I scp the zip from server to local and then checksum it, they match… so it looks like there is something that broke the zip during the transfer but this only happens with large file(s) inside the zip.

Can someone tell me why is the huge file has different attributes stor than other? And why is it that the xml that I added has 0.0 fat whereas the others has 6.3?

JavaScript

I noticed that everything (eg: LUH and xml) after the huge file is lost after the file is being downloaded via browser.

Update2:

Ok, this is insane… so I unpack the zip on linux with unzip then repack it using zip and download the file the same way via the browser. I’m now losing different files in the archive… THIS MAKES ABSOLUTELY ZERO SENSE!

After I unpack and repack, I get this below, everything after the large file is not viewable in Windows.

JavaScript

Advertisement

Answer

PHP readfile() can get problematic with large files. Try using stream_copy_to_stream() instead:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement