通过 php 的 zip 与通过 winrar 的 zip 的大小不同

发布于 2024-09-24 19:22:09 字数 462 浏览 0 评论 0原文

我通过 php 创建一个 zip 存档 和另一个通过 winrar 的 zip 存档,但来自相同的文件。

两个档案的大小不同。通过 winrar 的文件更大(2 个字节)。

为什么 ?谢谢。

现在好了。 zip 是使用 php 正确创建的。

问题是我正在使用它发送它

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$name);
header('Content-Length: ' . filesize($name));

,但没有 ob_start();ob_end_clean();

这就是为什么通过标头发送的文件大小不同的原因。 无论如何,感谢您的帮助;)

i create one zip archive via php
and another zip archive via winrar, but from the same files.

size of two archives is different. the one via winrar is bigger (2 bytes).

why ? thanks.

OK NOW.
zip was created correctly using php.

problem was that i was sending it using

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$name);
header('Content-Length: ' . filesize($name));

and dont have there ob_start(); and ob_end_clean();

that's why the size of file which come via header was different..
anyway thanks for your help ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以可爱出名 2024-10-01 19:22:09

可能有很多理由。我敢打赌,因为它只有 2 个字节,winrar 会在压缩文件中添加一个特殊的识别标记,以知道它是由 winrar 完成的。

另一种可能性是您可以设置不同级别的压缩,并且您的 php zip 函数可能设置为更高的压缩率。要么是真的,要么可能是真的,真正找出答案的唯一方法是使用十六进制编辑器并检查这两个文件,看看差异可能在哪里。

另一种检查方法是压缩不同大小的文件(但相同的文件)并查看差异是否始终为两个字节。如果它始终是两个字节,那么 winrar 会添加一个识别标记。如果不是,那就是不同的压缩率。

Could be plenty of reasons. My bet, since it is only 2 bytes, is that winrar adds a special identifying mark to the archive to know it was done by winrar.

The other possibility is that you can set different levels of compression, and your php zip function maybe set to a higher rate of compression. Either or could be true, only way to really find out is to use a hex editor and examine the two files and see where the difference may lay.

The other way to check is by zipping different file sizes (but the same files) and see if the difference is always two bytes. If it is always two bytes, well winrar adds an identifying mark. If it is not, well it is different compression rates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文