$zip = new ZipArchive();
// the string "file1" is the name we're assigning the file in the archive
$zip->addFile(file_get_contents($filepath1), 'file1'); //file 1 that you want compressed
$zip->addFile(file_get_contents($filepath2), 'file2'); //file 2 that you want compressed
$zip->addFile(file_get_contents($filepath3), 'file3'); //file 3 that you want compressed
echo $zip->file(); //this sends the compressed archive to the output buffer instead of writing it to a file.
有人可以确认一下吗:
我有一个文件夹,里面有test1.doc、test2.doc和test3.doc。
根据上面的例子,file1(file2和file3)可能只是test1.doc等。
我需要对"$filepath1"做些什么吗?那是包含这三个文档的文件夹目录吗?
对不起,我的问题很基础。