I am currently facing an issue while trying to decompress a ZIP file that utilizes Deflate64 compression in PHP using the ZipArchive class. The extraction process seems to be working well for regular Deflate compression, but encounters difficulties when dealing with Deflate64.
Here’s an example of a successful extraction using regular Deflate compression:
$zip = new ZipArchive();
$zip->open('deflate.zip');
$zip->extractTo('/tmp/test_extract');
(bool) true
However, when attempting to extract a ZIP file that uses Deflate64 compression, the process fails:
$zip = new ZipArchive();
$zip->open('deflate64.zip');
$zip->extractTo('/tmp/test_extract');
(bool) false
Furthermore, checking if Deflate64 compression is supported using ZipArchive::isCompressionMethodSupported
returns false:
ZipArchive::isCompressionMethodSupported(ZipArchive::CM_DEFLATE64);
(bool) false
On the other hand, regular Deflate compression is supported:
ZipArchive::isCompressionMethodSupported(ZipArchive::CM_DEFLATE);
(bool) true
I am reaching out to the community to inquire if there is a known solution or workaround to enable the extraction of ZIP files using Deflate64 compression in PHP’s ZipArchive class. Any insights or code snippets that address this issue would be greatly appreciated.
Thank you in advance for your assistance!
2
Answers
As you have rightly checked, Deflate64 is not supported by the standard PHP ZipArchive
I would suggest using 7zip
It looks like the libzip team just don’t want to support deflate64 yet, you can use zlib to inflate each file individually.
Note: You need to create subfolders by yourself.