2010-01-07 28 views
2

我期待创建一个表格,用户将从小册子列表中进行选择。总共10个。下载表格 - 选择文件combile到邮政编码

他们可能只想下载3本小册子,或6或1或9,但是他们想要选择他们想要的小册子,然后脚本将包含所需小册子的zip文件合并在一起。

任何人都可以提出任何建议吗?

回答

1

PHP有Zip extension这个用例从手册页

例为ZipArchive::addFile

$zip = new ZipArchive; 
if ($zip->open('test.zip') === TRUE) { 
    $zip->addFile('/path/to/index.txt', 'newname.txt'); 
    $zip->close(); 
    echo 'ok'; 
} else { 
    echo 'failed'; 
} 

所以,你需要做的就是增加用户选择的ZipArchive文件,然后发送通过header()存档:

header('Content-type: application/zip'); 
header('Content-Disposition: attachment; filename="test.zip"'); 
readfile('test.zip');