title: Invalid or unitialized Zip object
body: <pre><code>if(isset($_POST['items'])) {
      // open zip
      $zip_path = 'downloadSelected/download.zip';
      $zip = new ZipArchive();
  
      if ($zip-&gt;open($zip_path, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== TRUE) {
         die ("An error occurred creating your ZIP file.");
       }
  
       foreach ($_POST['items'] as $path) {
          // generate filename to add to zip
          $filepath = 'downloads/' . $path . '.zip';
          if (file_exists($filepath)) {
                  $zip-&gt;addFile($filepath, $path . '.zip') or die ("ERROR: Could not add the file $filename");
          }
          else {
                  die("File $filepath doesnt exit");
                  }
          $zip-&gt;close();
         } }
  </code></pre>
  
  <p>I am getting <em>Warning: <code>ZipArchive::addFile()</code> [function.ZipArchive-addFile]: Invalid or unitialized Zip object</em>. what could be problem? I tried many methods but in vain.
  I am able to create and initiate download when I select one file. However, I get above error when I select more than one file. </p>