支持密码加密,支持整个文件夹的压缩。
目前用到的这个不支持加密码。最好能直接下载源文件与说明文件。

解决方案 »

  1.   

    用COM类实现,下面的例子摘自PHP在线手册:
    http://php.net/manual/en/class.com.phpdpchiesa at hotmail dot com
    28-Mar-2009 05:35
    Here's a way to create an AES-Encrypted ZIP file in PHP, using DotNetZip via the COM class. <?php
    try
    {
      $fname = "zip-generated-from-php-" . date('Y-m-d-His') . ".zip";
      $zipOutput = "c:\\temp\\" . $fname;
      $zip = new COM("Ionic.Zip.ZipFile");
      $zip->Name = $zipOutput;
      $dirToZip= "c:\\temp\\psh";
      #$dirToZip= "c:\\dinoch\\webs\\php";
      $zip->Encryption = 3;
      $zip->Password = "AES-Encryption-Is-Secure";
      $zip->AddDirectory($dirToZip);
      $zip->Save();
      $zip->Dispose();  if (file_exists($zipOutput))
      {
        header('Cache-Control: no-cache, must-revalidate');
        header('Content-Type: application/x-zip'); 
        header('Content-Disposition: attachment; filename=' . $fname);
        header('Content-Length: ' . filesize($zipOutput));
        readfile($zipOutput);
        unlink($zipOutput);
      }
      else 
      {
        echo '<html>';
        echo '  <head>';
        echo '  <title>Calling DotNetZip from PHP through COM</title>';
        echo '  <link rel="stylesheet" href="basic.css"/>';
        echo '  </head>';
        echo '<body>';
        echo '<h2>Whoops!</h2>' . "<br/>\n";
        echo '<p>The file was not successfully generated.</p>';
        echo '</body>';
        echo '</html>';
      } 
    }
    catch (Exception $e) 
    {
        echo '<html>';
        echo '  <head>';
        echo '  <title>Calling DotNetZip from PHP through COM</title>';
        echo '  <link rel="stylesheet" href="basic.css"/>';
        echo '  </head>';
        echo '<body>';
        echo '<h2>Whoops!</h2>' . "<br/>\n";
        echo '<p>The file was not successfully generated.</p>';
        echo '<p>Caught exception: ',  $e->getMessage(), '</p>', "\n";
        echo '<pre>';
        echo $e->getTraceAsString(), "\n";
        echo '</pre>';
        echo '</body>';
        echo '</html>';
    }?>