title: PHP ZipArchive doesn't create a zip archive. What to fix in the code?
body: <p>I have an .srt file located in the files/srt/username/filename.srt directory. I need to be able to download it in the browser, but to make this possible I have to zip the file first.
  I found the following code online:</p>
  
  <pre><code>function download_zip() {
      if (isset($_POST['download_srt'])) {
          $zip = new ZipArchive();
          $zip-&gt;open("files/srt/".$_SESSION['user_name']."/".$_POST['download_srt'].".zip", ZipArchive::CREATE);
          // output: files/srt/username/filename.srt.zip
  
          $zip-&gt;addFile($_POST['download_srt']);
          // output of $_POST['download_srt']: filename.srt
  
          $zip-&gt;close();
      }
  }
  </code></pre>
  
  <p>The code is called when a submit button is pressed and the $_POST data are sent.
  The function works, but no ZIP file gets created in the same directory as the original srt file. No error messages appear.</p>