ZipArchives存储绝对路径 [英] ZipArchives stores absolute paths

查看:527
本文介绍了ZipArchives存储绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用相对路径压缩文件吗?

Can I zip files using relative paths?

例如:

$ zip-> addFile('c:/wamp/www/foo/file.txt');

ZIP应该有目录结构如下:

the ZIP should have a directory structure like:

foo
 -> file.txt

而不是:

wamp
 -> www
     -> foo
         -> file.txt

喜欢默认情况下...

like it is by default...

ps:我的完整代码是这里(我使用ZipArchive将目录的内容压缩为zip文件)

ps: my full code is here (I'm using ZipArchive to compress contents of a directory into a zip file)

推荐答案

请参阅 addFile() 函数定义,您可以覆盖归档文件名:

See the addFile() function definition, you can override the archive filename:

$zip->addFile('/path/to/index.txt', 'newname.txt');

这篇关于ZipArchives存储绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆