求一个php zip类 支持密码加密,支持整个文件夹的压缩。目前用到的这个不支持加密码。最好能直接下载源文件与说明文件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用COM类实现,下面的例子摘自PHP在线手册:http://php.net/manual/en/class.com.phpdpchiesa at hotmail dot com28-Mar-2009 05:35Here's a way to create an AES-Encrypted ZIP file in PHP, using DotNetZip via the COM class. <?phptry{ $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>';}?> 路径问题 这个怎么插不进去? do?id=xxx 和 htm?id=xxx 类似这个是用什么脚本语言?? php上传图片的无法获取宽高! 如何根据一个变量的数值大小动态的分配颜色 开发php时您曾遇到的最大难题是什么 表格的标题栏不动,下面的数据可以滚动,这样效果怎么做? PHP:请问怎样将字符串转换为数字,比如将“1000”转换为1000. 为什么有的php程序会自动停止执行? 简单问题,高份奉送 生僻字无法显示的原因? extension_dir无论怎么设置都是c:\php5
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>';
}?>