下面的代码只能压缩。但生成不了压缩包右边的说明,怎么才能生成一个压缩包还带右边的压缩包说明的呢,
代码怎么改呢?
<?
$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.";
?>
1 个解决方案
#1
参考一下这个教程吧 http://php.goldenweb.it/it/html/function.ziparchive-setarchivecomment.html
<?php
$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.";
?>
<?php
$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.";
?>
#1
参考一下这个教程吧 http://php.goldenweb.it/it/html/function.ziparchive-setarchivecomment.html
<?php
$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.";
?>
<?php
$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.";
?>