Zip and Force Download Folder or File depending on selected items (File Manager System)
<p>I am trying to build a simple file manager system for my clients and am having trouble with the download section. Allowing users to download files or folders separately or as a bunch. </p>

<p>Every user has a directory in <code>../useraccounts/</code> named as their account ID for example: <code>k462da</code>. The entire directory would be <code>../useraccounts/k462da</code>.</p>

<p>On a page I am listing all of their sub directories and files stored within those user accounts. These files have separate download buttons or checkboxes next to them. If the user decides to download one file, that one file or directory will be downloaded. If the user decides to download multiple directories and/or files, it will download them in to a ZIP under the user account ID.</p>

<p>Here is what I have so far for the multiple downloads:</p>

<pre><code>&lt;input type="checkbox" name="fileselect[]" value="&lt;? echo $filename; ?&gt;"&gt;


if(isset($_POST['download_all'])){
      $file = $_POST['fileselect'];
      foreach ($file as $files=&gt;$name) {
          if (substr($name, -1) == '/') {
            //// DOWNLOAD DIRECTORIES
          } else {
            //// DOWNLOAD FILES
          }
      }

  } 
</code></pre>

<p>I have attempted everything I can find on the first couple of pages of Google for different searches and NOTHING seems to work, at all, for either rule. I am hoping somebody might be able to point me in the right direction here? </p>