zip from php popen and from command line different results
Get the solution ↓↓↓I am trying to offer download of a whole directory from an apache using php I use the answer from this question Zip Stream in PHP
But when I compare (with cksum) the downloaded zip and the zip created with the same command from the command line the resuts are different.
Here is what I do from PHP :
{-code-1}
Here is what I do from the command line :
cd "/path/to/myfolder"
/usr/bin/zip -qr -1 - . > /tmp/myfolder.zip
I want both cksum are the same but they are not. What am I missing ? What to do so that they are the same ?
EDIT
Here is a diff between zipinfo for both files (on the left downloaded file and on the right command line file).
7,9c7,9
< Zip archive file size: 248145030 (000000000ECA6486h)
< Actual end-cent-dir record offset: 248145008 (000000000ECA6470h)
< Expected end-cent-dir record offset: 248145008 (000000000ECA6470h)
---
> Zip archive file size: 248144998 (000000000ECA6466h)
> Actual end-cent-dir record offset: 248144976 (000000000ECA6450h)
> Expected end-cent-dir record offset: 248144976 (000000000ECA6450h)
16c16
< is 248144779 (000000000ECA638Bh).
---
> is 248144747 (000000000ECA636Bh).
31c31
< compression sub-type (deflation): normal
---
> compression sub-type (deflation): fast
33c33
< extended local header: yes
---
> extended local header: no
59,60d58
< There are an extra 16 bytes preceding this file.
<
63,64c61,62
< offset of local header from start of archive: 248143809
< (000000000ECA5FC1h) bytes
---
> offset of local header from start of archive: 248143793
> (000000000ECA5FB1h) bytes
70c68
< compression sub-type (deflation): normal
---
> compression sub-type (deflation): fast
72c70
< extended local header: yes
---
> extended local header: no
EDIT2
replacing the-1
for fastest compression by-Z store
for no compression reduces the differences, but still not OK.
7,9c7,9
< Zip archive file size: 249693306 (000000000EE2047Ah)
< Actual end-cent-dir record offset: 249693284 (000000000EE20464h)
< Expected end-cent-dir record offset: 249693284 (000000000EE20464h)
---
> Zip archive file size: 249693274 (000000000EE2045Ah)
> Actual end-cent-dir record offset: 249693252 (000000000EE20444h)
> Expected end-cent-dir record offset: 249693252 (000000000EE20444h)
16c16
< is 249693055 (000000000EE2037Fh).
---
> is 249693023 (000000000EE2035Fh).
32c32
< extended local header: yes
---
> extended local header: no
58,59d57
< There are an extra 16 bytes preceding this file.
<
62,63c60,61
< offset of local header from start of archive: 249690256
< (000000000EE1F890h) bytes
---
> offset of local header from start of archive: 249690240
> (000000000EE1F880h) bytes
70c68
< extended local header: yes
---
> extended local header: no
Solution
Here is the command I am using to get identical results. I keep the question opened so that someone can explain differences between popen and terminal execution of the command.
/usr/bin/zip -qr -0 -fd -fz- - .
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 8.0.2".
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.