title: Zip content is cleared after downloading it in php
body: <p>The Problem is that when downloading the zip, its content gets deleted.
  I use this code to create the zip and add the files to it:</p>
  <pre><code>    $zipName = &quot;full path&quot;;
      $zip = new ZipArchive();
      $zip-&gt;open($zipName, ZipArchive::CREATE);
      for ($i = 0; $i &lt; $length; $i++) {
          if ($ausgabeArray[$i][&quot;filePath&quot;] != '') {
              $zip-&gt;addFromString(basename($ausgabeArray[$i][&quot;filePath&quot;]), file_get_contents($ausgabeArray[$i][&quot;filePath&quot;]));
          }
      }
      $zip-&gt;close();
      for ($i = 0; $i &lt; $length; $i++) {
          unlink($ausgabeArray[$i][&quot;filePath&quot;]);
      }
  </code></pre>
  <p>And I use this code to download the zip:</p>
  <pre><code>        header(&quot;Content-disposition: attachment; filename=&quot; . $name);
          header(&quot;Content-type: application/&quot;.$endung);
          readfile($path);
          unlink($path);
          //name = basename from the path of the zip
          //path = full path to the zip
          //endung = zip
  </code></pre>
  <p>This worked fine on the old server, but after changing it, it stopped working. I stopped the code once before <code>readfile($path);</code> and viewed the zip in the folder and downloaded it from there, everything worked fine this way, but this is of course no option for anybody who has no permission for the server directories.</p>
  <p>We use this server:</p>
  <ol>
  <li>Ubuntu 20.04.2 LTS</li>
  <li>Apache/2.4.41 (Ubuntu)</li>
  <li>7.3.29 FPM-Application</li>
  </ol>
  <p>I'm not sure if the problem has anything to do with the server change or just my code, but I didn't change a thing, and now it is not working any more, so I think it is possible.
  I hope someone had this problem before and can help me. Thanks!</p>