如何将文件夹内的文件压缩为zip Archive
$source = "/Filelist/"
$filter = new Zend_Filter_Compress(
array(
'adapter' => 'Zip',
'options' => array(
'archive' => test.zip
)
)
);
$result = $filter->filter($source);
该函数工作正常,问题是我想获取 test.zip 中的文件列表。但是现在我在存档中获取文件夹 Filelist 。
似乎是因为这一行:
$content = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
并且真实路径正在删除 /
。我该如何解决这个问题?
$source = "/Filelist/"
$filter = new Zend_Filter_Compress(
array(
'adapter' => 'Zip',
'options' => array(
'archive' => test.zip
)
)
);
$result = $filter->filter($source);
The function works fine, the problem is that I want to get the file list inside the test.zip. However now I am getting the folder Filelist inside the archive.
It seems to be because of this line:
$content = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
and the realpath is removing /
. How do I resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看代码,我没有看到这样做的方法。 Zend_Filter_compress_Zip 检查它是否是一个目录,如果是,则调用:
Looking at the code, I don't see a way of doing that. Zend_Filter_Compress_Zip checks if it is a dir, and if it is, calls: