php:我可以压缩没有完整路径的 glob 文件吗?
这段代码就像在糟糕的一天里送来一批神奇的新鲜薯片:纯粹的快乐。但是当我提取存档时,文件嵌套在它们存储在服务器上的路径中。我不喜欢。我如何在没有完整路径的情况下压缩 glob;只是文件。
$zip = new ZipArchive();
$zip->open("_dox/pdftmp/".$_SESSION['archiveName'], ZipArchive::CREATE);
$files_pdf = glob('_dox/pdftmp/*.pdf');
foreach ($files_pdf as $file)
{
$zip->addFile($file);
}
$zip->close();
请记住:只有文件,没有额外的文件夹。
写!
this code works like a magic batch of fresh potato chips on a really bad day: PURE JOY. but when i extract the archive, the files are nested in the path they were stored in on the server. me no likey. how do i zip the glob without the full path; just the files.
$zip = new ZipArchive();
$zip->open("_dox/pdftmp/".$_SESSION['archiveName'], ZipArchive::CREATE);
$files_pdf = glob('_dox/pdftmp/*.pdf');
foreach ($files_pdf as $file)
{
$zip->addFile($file);
}
$zip->close();
remember: just files, no extra folders.
WR!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
指定 zip 中文件的“本地名称”。请参阅
addFile()
文档。Specify the "local name" that the files will have inside the zip. See the
addFile()
docs.