title: PHP Zip file download error when opening
body: <p>I need to download a zip file from a website as I am going to require to coalesce multiple files in a single download <em>(up to 100 individual files-ish)</em>.</p>
  
  <p>When attempting to create the zip file, it downloads as intended, the file name appears in the format <em>"YYYY.MM.DD - HH.MM.SS"</em> also as intended. My issue occurs when attempting to open the zip file in windows 7 <em>(or winzip)</em> - I get the error message below. This happens repeatedly from multiple attempts.</p>
  
  <p>I assume that I have made an error while coding the creation or download of the zip file, rather than the zip file format itself being an issue as I can open different zip files - can anyone see the mistake I have probably made? <em>(code included below error image)</em></p>
  
  <p><a href="https://imgur.com/Yw52XOA" rel="nofollow noreferrer"><img src="https://i.imgur.com/Yw52XOA.png" title="Hosted by imgur.com" /></a></p>
  
  <p>I have attempted to use <a href="https://stackoverflow.com/questions/1754352/download-multiple-files-as-zip-in-php">Download multiple files as a zip-file using php</a> as a reference.</p>
  
  <pre><code>//backup file name based on current date and time
  $filename = date("Y.m.j - H.i.s");
  //name of zip file used when downloading
  $zipname = 'temp.zip';
  //create new zip file
  $zip = new ZipArchive;
  $zip-&gt;open($zipname, ZipArchive::CREATE);
  //yes, I know the zip file is empty currently - I've cut the code from here for
  //now as the zip file doesn't function with / without it currently
  $zip-&gt;close();
  
  //download file from temporary file on server as '$filename.zip'
  header('Content-Type: application/zip');
  header('Content-disposition: attachment; filename='.$filename.'.zip');
  header('Content-Length: ' . filesize($zipname));
  readfile($zipname);
  </code></pre>