我希望创建一个表单,用户可以从手册列表中进行选择。总共10个。
他们可能只想下载 3 份小册子、或 6 份、或 1 份、或 9 份小册子,但想法是他们选择所需的小册子,然后用脚本组合一个包含所需小册子的 zip 文件。
任何人都可以提出任何建议吗?
PHP 有一个邮编扩展 http://php.net/manual/en/book.zip.php对于这个用例
手册页中的示例ZipArchive::addFile http://www.php.net/manual/en/function.ziparchive-addfile.php
$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() http://php.net/manual/de/function.header.php:
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="test.zip"');
readfile('test.zip');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)