1

I want to zip a large folder of 50K files on Windows Server. I'm currently using this code:

include_once("CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;

$directoryToZip="repository";
$outputDir=".";
$zipName="CreateZipFileWithPHP.zip";

define("ZIP_DIR",1); //


if(ZIP_DIR)
{
//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);
}else
{
//?
}

$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
$createZipFile->forceDownload($zipName);
@unlink($zipName);

Everything works fine until around 2K image files. But this is not what I want to get. I'm willing to process to zip like 50K images at least. Meanwhile my script gets this error:

Fatal error: Maximum execution time of 360 seconds exceeded in C:\xampp\htdocs\filemanager\CreateZipFile.inc.php on line 92

$newOffset = strlen(implode("", $this->compressedData));

I'm searching for any solution to proceed such a huge amount of files. I currently use XAMPP on Windows Server 2008 Standard. Is there any possibility to make small parts of the zips, use a system command and maybe external tool to pack them and then send it to header to download?

http://pastebin.com/iHfT6x69 for CreateZipFile.inc.php

4

2 回答 2

0

您需要较小的文件还是快速提供的文件?对于没有压缩和没有内存泄漏的快速服务,您可以尝试将系统命令与 gzip 之类的 zip 软件一起使用并打开压缩。

这些文件可能会变得很大,但会作为一个文件快速提供。

于 2013-11-01T20:03:37.847 回答
0

试试这个..增加执行时间

ini_set('max_execution_time', 500);

500 是 os 秒数 将其更改为您喜欢的任何内容

于 2013-11-01T19:49:44.307 回答