使用php下载多个文件作为zip文件夹
答
你可以看看ZipArchive
,你就可以创建拉链并让用户下载它。
Cletus提供了一个非常好的答案there。我谦恭地复制到这里他的样本
$files = array('readme.txt', 'test.html', 'image.gif');
$zip = new ZipArchive;
$zip->open('file.zip', ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
并流呢:
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=filename.zip');
header('Content-Length: ' . filesize($zipfilename));
readfile($zipname);
确定ragez我会给予一个尝试 – 2009-11-19 05:24:22
类ZipFile中没有找到,我得到这个错误 – 2009-11-19 05:30:31
@netcoder:谢谢你的编辑。 – RageZ 2011-02-07 02:35:30