ZipArchives存储绝对路径

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');