Home  >  Article  >  Backend Development  >  用ZipArchive如何写才能生成压缩包右边的注解?(就是右边的关于一些关于压缩包的说明)

用ZipArchive如何写才能生成压缩包右边的注解?(就是右边的关于一些关于压缩包的说明)

WBOY
WBOYOriginal
2016-06-13 12:54:021076browse

用ZipArchive怎么写才能生成压缩包右边的注解?(就是右边的关于一些关于压缩包的说明)

本帖最后由 bxline 于 2013-02-10 12:48:59 编辑 用ZipArchive怎么写才能生成压缩包右边的注解?(就是右边的关于一些关于压缩包的说明)
下面的代码只能压缩。但生成不了压缩包右边的说明,怎么才能生成一个压缩包还带右边的压缩包说明的呢,
代码怎么改呢?


$zip = new ZipArchive();
if ($zip->open('d:/aa.zip', ZIPARCHIVE::CREATE) !== TRUE) {
   die ("Could not open archive");
}
$zip->addFile("d:/bb.txt",basename("bb.txt"));
$zip->close();
echo "Archive created successfully.";  
?>

------解决方案--------------------
参考一下这个教程吧 http://php.goldenweb.it/it/html/function.ziparchive-setarchivecomment.html

$zip = new ZipArchive();
if ($zip->open('d:/aa.zip', ZIPARCHIVE::CREATE) !== TRUE) {
   die ("Could not open archive");
}
$zip->addFile("d:/bb.txt",basename("bb.txt"));
$zip->setArchiveComment('注解');
$zip->close();
echo "Archive created successfully.";  
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn