title: ZipArchive ExtractTo() Permission Denied
body: <p>I'm trying to extract zip files from a folder into a subfolder. The error I'm recieving is:</p>
  
  <pre><code>Warning: ZipArchive::extractTo(XXXX): failed to open stream: Permission denied in /var/www/html/update_alerts2.php on line 97
  extracted
  </code></pre>
  
  <p>Code :</p>
  
  <pre><code>    public function extractFiles($inputDir,$outputDir) {
          $files_to_extract = $this-&gt;getFiles($inputDir);
          $zip = new ZipArchive();
          foreach ($files_to_extract as $file) {
  
              echo $file;
              $res = $zip-&gt;open($inputDir . $file);
              if ($res) {
                  $zip-&gt;extractTo($outputDir);
                  $zip-&gt;deleteName($inputDir . $file);
                  $zip-&gt;close();
              } else {
                  echo 'failed, code:' . $res;
              }
          }   
      }
  </code></pre>
  
  <p>I've tried setting permissions to 777 but I still get the error. What are the possible ways I can fix this issue (I'm using centos7 and apache) ?</p>