title: PHP ZipArchive download working but not adding files to zip
body: <p>I know there is many questions regarding the ZipArchive and how it works but after following all these I still can't get my program to work.</p>
  
  <p>I don't know where i'm going wrong because I have die methods in and none of them are getting activated.</p>
  
  <pre><code>$path = "/export/scripts/CLOUD/logs/web/Private_Testbox/Jan_28_2013_16_20_44_atvts78_rollout_config/";
  
  $fileName = explode('/', $path);
  $zipname = $fileName[count($fileName) - 2];
  
  $zip = new ZipArchive;
  $handle = opendir($path);
  
  //Check whether Zip can be opened
  if ($zip-&gt;open($zipname, ZIPARCHIVE::CREATE) !== TRUE) {
      die("Could not open archive");
  }
  
  //Add all files to an array
  while ($file = readdir($handle)) 
  {
      $zip-&gt;addFile($path, $file);
  }
  
  closedir($handle);
  $zip-&gt;close();
  
  //Send zip folder 
  header('Content-Type: application/zip');
  header('Content-disposition: attachment; filename=' . $zipname . '.zip');
  readfile($zip);
  </code></pre>
  
  <p>This file downloads the zip folder but there is never anything in it.</p>
  
  <p>Thanks for help in advance.</p>