我正在用PHP开发小应用程序接口,我需要创建一个动态压缩文件,但是内容(文件)也是用PHPExcel库动态创建的,有人知道怎么做吗?
发布于 2012-03-09 19:02:37
看起来你可以做到这一点:
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
$zip->addFromString('test.txt', 'file content goes here');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>因此,您必须使用addFromString方法以字符串形式从PHPExcel获取内容。
有关更多信息,请查看此处:http://php.net/manual/en/ziparchive.addfromstring.php
https://stackoverflow.com/questions/9632838
复制相似问题