title: ZipArchive - extract folder
body: <p>I am allowing users to upload portfolios in ZIP archives on my site.</p>
  
  <p>The problem is that most archives have the following folder structure:</p>
  
  <pre><code>zipfile.zip
    - zipfile
      - file1.ext
      - file2.ext
      - file3.ext
  </code></pre>
  
  <p>is there any way to simply put the files (not the directory) onto my site (so the folder structure of their portfolio is like so)</p>
  
  <pre><code>user_name
    - portfolio
      - file1.ext
      - file2.ext
      - file3.ext
  </code></pre>
  
  <p>it currently uploads them like so:</p>
  
  <pre><code>user_name
    - portfolio
      - zipfile
        - file1.ext
        - file2.ext
        - file3.ext
  </code></pre>
  
  <p>which creates all kinds of problems!</p>
  
  <p>I have tried doing this:</p>
  
  <pre><code>$zip = new ZipArchive();
  $zip-&gt;open($_FILES['zip']['tmp_name']);
  $folder = explode('.', $_FILES['zip']['name']);
  end($folder);
  unset($folder[key($folder)]);
  $folder = (implode('.', $folder));
  $zip-&gt;extractTo($root, array($folder));
  $zip-&gt;close();
  </code></pre>
  
  <p>to no avail.</p>