PHP头条
热点:

怎么用php向服务器已存在的zip文件中增加一个文件


如何用php向服务器已存在的zip文件中增加一个文件
请注意,不是生成zip,在不解开服务器zip文件的前提下,添加一个文件进去。请问我该如何做。

------解决方案--------------------
加一个zip模块进去
使用方式如下:

$zip = new ZipArchive();
$filename = "./test112.zip";

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}

$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
$zip->addFile($thisdir . "/too.php","/testfromfile.php");
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
?>
------解决方案--------------------
另外想说:
1、永远不要责怪别人不明白,只能责怪自己没说清楚。
2、不要以为自己总是对的,偶尔也看看别人是不是说的也是对的。

www.phpzy.comtrue/phprm/47567.htmlTechArticle怎么用php向服务器已存在的zip文件中增加一个文件 如何用php向服务器已存在的zip文件中增加一个文件 请注意,不是生成zip,在不解开服务器zip文件的前提下,添加一个文件进去。请问...

相关文章

PHP之友评论

今天推荐