douan3182 2016-08-11 02:06
浏览 3266
已采纳

PHP:ZipArchive :: close():重命名临时文件失败:没有这样的文件或目录

I cannot create a zip file. It gives me this error. A search turned up no results. This is my function.

  function CompressFile($fromExtractedFile)
  {
      $archive = new ZipArchive;

      if ($archive->open($fromExtractedFile.".zip", ZipArchive::OVERWRITE | ZipArchive::CREATE) === TRUE) {
          $archive->addFile($fromExtractedFile, 'payload.csv');
          $archive->close();
      }
      else {
          throw new Exception ("Compress operation to ZIP file failed. $fromExtractedFile -> $fromExtractedFile.zip");
      }
      return $fromExtractedFile.".zip";
  }

Console:

Compressing /tmp/bing_PeUYiT
PHP Warning 'yii\base\ErrorException' with message 'ZipArchive::close(): Renaming temporary file failed: No such file or directory'

Docs: http://php.net/manual/en/book.zip.php

PHP 5.6, Win 8.1, Cygwin 2.5.2

Here is the same in PsySh:

>>> $archive = new ZipArchive
=> ZipArchive {#199
     +"status": 0,
     +"statusSys": 0,
     +"numFiles": 0,
     +"filename": "",
     +"comment": "",
   }
>>> $archive->open('/tmp/bing_PeUYiT.zip', ZipArchive::OVERWRITE|ZipArchive::CREATE)
=> true
>>> $archive->addFile('/tmp/bing_PeUYiT', 'payload.csv')
=> true
>>> $archive->close()
PHP warning:  ZipArchive::close(): Renaming temporary file failed: No such file or directory on line 1
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 react native ios端amap问题
      • ¥15 fortran95中5个学生分不同学号求数学语文英语计算机四门课程的每名学生的平均分以及名次以及单科成绩的平均分
      • ¥30 excel vba 执行从 1 到 100 的乘法。执行结果保存成二维数组
      • ¥15 数字电子技术基础设计实验
      • ¥15 ue5运行非常卡顿,是电脑配置原因吗
      • ¥50 有没有大佬看一下关于思科的这道题怎么做
      • ¥30 求十字路口交通灯S7-200plc,今天早上八点前。
      • ¥20 如何用智能手表oppowatch3实现个人热点功能
      • ¥15 运营商打开wanpush会有怎么样的危害
      • ¥15 Java编程题,定义一个时钟