简体   繁体   English

PHP zip解压缩和重命名

[英]PHP zip extract and rename

The code below sort of works. 下面的代码有点工作。

$zip = new ZipArchive;
if($zip->open($path) === TRUE) {
   $zip->renameName('list.csv', 'list'.$batch_id.'.csv');
   $zip->extractTo('list_output');
   $zip->close();
}

The file inside the zip is renamed, but it does not extract. zip中的文件已重命名,但不会提取。 If I remove the renameName line then it extracts fine. 如果我删除renameName行,那么它提取正常。 I need it to do both. 我需要它来做两件事。

What about? 关于什么?

$zip = new ZipArchive;
if($zip->open($path) === TRUE) {
   $zip->extractTo('list_output');
   $zip->close();
}

rename('list_output/list.csv', 'list_output/list'.$batch_id.'.csv');

Would be easier on the CPU/Memory too. 在CPU /内存上也会更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM