使用哪锋迅方式如下:
<?php
$zip = new ZipArchive()
$filename = "基银./test112.zip"
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>")
}
$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt. ")
$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt. ")
$zip->addFile($thisdir . "/too.php","/testfromfile.php")
echo "numfiles: " . $zip->numFiles . " "
echo "status:" . $zip->status . "李此 "
$zip->close()
?>
向压缩包添加文件的方法迅烂在官方文档中有说明:Updating
using ICSharpCode.SharpZipLib.Zippublic void UpdateExistingZip() {
ZipFile zipFile = new ZipFile(@"c:\temp\existing.zip")
// Must call BeginUpdate to start, and CommitUpdate at the end.
zipFile.BeginUpdate()
zipFile.Password = "whatever" // Only if a password is wanted on the new entry
// The "Add()" method will add or overwrite as necessary.
// When the optional entryName 庆兆parameter is omitted, the entry will be named
// with the full folder path and without the drive e.g. "temp/folder/test1.txt".
//
zipFile.Add(@"c:\temp\folder\test1.txt")
// Specify the entryName parameter to modify the name as it appears in the zip.
//
zipFile.Add(@"c:\temp\folder\test2.txt", "test2.txt")
// Continue calling .Add until finished.
// Both CommitUpdate and Close must be called.
zipFile.CommitUpdate()
zipFile.Close()
}
在使誉昌租用开源项目的时候建议先去看它的wiki
zip -m b.zip/aaa/bbb/樱销ccc a.txt参考:http://www.php100.com/html/webkaifa/Linux/2009/1213/3652.html (我最喜欢誉颂弯的庆闷网站之一)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)