title: php zipArchive->close() returns False
body: <p>I have a function which creates a zip file.</p>
  
  <pre><code>function zipDoc($docRoot,$archiveName,$testsFolder){
  $filename = tempnam($testsFolder, "doc");
  $cwd=getcwd();
  chdir ($docRoot);
  
  
   if (is_writeable($docRoot)){
      echo $docRoot." is writeable";
    }
      $zip = new ZipArchive();
      if ($zip-&gt;open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
          exit("cannot open &lt;$filename&gt;\n");
      }
    echo "&lt;br/&gt;";
    if (is_writeable(dirname($filename))){
      echo dirname($filename)." is writeable";
    }
      $folders = array ("_rels","docProps","word");
      // initialize an iterator
      // pass it the directory to be processed
      foreach ($folders as $folder){
          $iterator = new RecursiveIteratorIterator(new    RecursiveDirectoryIterator($folder."/"));
          // iterate over the directory
          // add each file found to the archive
          foreach ($iterator as $key=&gt;$value) {
        if (!is_readable($key)){
             echo  "File ".$key." not readeble";
        }
              $zip-&gt;addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
          }
      }
      $zip-&gt;addFile("[Content_Types].xml");
  
      // close and save archive
      echo "&lt;br/&gt;";
    if ($zip-&gt;close()){
    echo $filename." is Closed";
    }
    else{
    echo $filename." is not closed";
    }
      $newname=str_replace(".tmp",".docx",$filename);
      rename($filename,$newname);
      chdir($cwd);
      return $newname;
  }
  </code></pre>
  
  <p>The output is that both folders are writeable (I checked that on filesystem as well), and that the zip file is not closed!!!
  Any suggestions, why is it not closing?
  Edit: Status of file after close() method call is 3670068, function rename says that file is being used by another process. The file is created but has 0kb.</p>