直接代码,简洁明了
$path = __DIR__."/a.txt"; $filename = "test.zip"; $zip = new ZipArchive(); $zip->open($filename,ZipArchive::CREATE); //打开压缩包 $zip->addFile($path,basename($path)); //向压缩包中添加文件 $zip->close(); //关闭压缩包
直接代码,简洁明了
$path = __DIR__."/a.txt"; $filename = "test.zip"; $zip = new ZipArchive(); $zip->open($filename,ZipArchive::CREATE); //打开压缩包 $zip->addFile($path,basename($path)); //向压缩包中添加文件 $zip->close(); //关闭压缩包