这就是我需要的
$a=array('folder'=>'anyfolder','filename'=>'anyfilename','filedata'=>'anyfiledata');
我需要使用 $a 中的压缩数据创建一个变量 $zip 并将此 $zip 输出到浏览器窗口中
header('Content-type: application/octetstream');
echo $zip;
我找到的所有库,它们都会打包文件并在磁盘上物理创建 zip 文件。我需要使用内存动态地执行此操作。是否有任何示例说明如何使用纯 php 的 zlib 来完成此操作,而无需研究 zip 格式规范?
UPD:
可以用以下方法完成吗创建ZIP http://www.phpclasses.org/package/2322-PHP-Create-ZIP-file-archives-and-serve-for-download.html class?
UPUPD:
是的。它可以=)
Yes, 创建ZIP http://www.phpclasses.org/package/2322-PHP-Create-ZIP-file-archives-and-serve-for-download.html类做到了。
require_once('CreateZipFile.php');
$zip = new CreateZipFile;
$zip->addFile('anyfiledata', 'anyfilename');
$zip->addFile('anyfiledata2', 'anyfolder/anyfilename.anyext');
$zip->addDirectory('anyemptydirwouldbecreatedinthiszipfile');
header('Content-disposition: attachment; filename='.'zipfile.zip'.'');
header('Content-type: application/octetstream');
echo $zip->getZippedfile();
die();
非常感谢呃。罗查克·乔汉
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)