1

我必须使用 php 创建一个 zip 文件。这些文件位于我的 Web 服务器的目录中。我必须添加这些文件(动态)并制作一个 zip 文件。

在 php 中使用小文件完美工作,但是当我尝试使用大于 200 MB 的文件制作 zip 时,我将花费更多时间来创建 zip。

那么有没有办法使用windows系统命令制作一个zip文件,可以通过PHP运行?这样我们就可以轻松快速地创建 zip 文件而不会丢失内存。

请帮忙

4

1 回答 1

1

You could try to implement a queue of some kind, perhaps in your database. You enqueue zip operations, while on the background a cron job of some kind does the zipping, and notifies your queue when it's finished.

This won't decrease processing time, but since zipping is a CPU and I/O heavy operation, it probably can't be sped up much. Using this technique you don't have to let your user wait until zipping is done, you could for example simply send an e-mail (with the link to the created zip file) when it's done.

于 2012-04-18T08:35:20.043 回答