title: AWS mkdir(): Permission denied
body: <p>I am working on AWS ec2 ubuntu machine. My code is in cakephp. When I try to upload any image with crating new folder, I got following warnings.</p>
  <blockquote>
  <p>Warning (2): mkdir(): Permission denied
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 1784]</p>
  <p>Warning (2): chmod() [function.chmod]: No such file or directory
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 1785]</p>
  <p>Warning (2):
  finfo::file(/var/www/html/app/webroot/files/user/image/35/)
  [finfo.file]: failed to open stream: No such file or directory
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 1955]</p>
  <p>Warning (2): mkdir() [function.mkdir]: Permission denied
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 1784]</p>
  <p>Warning (2): chmod() [function.chmod]: No such file or directory
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 1785]</p>
  <p>Warning (2):
  move_uploaded_file(/var/www/html/app/webroot/files/user/image/35/1439985339.jpg)
  [function.move-uploaded-file]: failed to open stream: No such file or
  directory [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line
  349]</p>
  <p>Warning (2): move_uploaded_file() [function.move-uploaded-file]:
  Unable to move '/tmp/phpqvcdzp' to
  '/var/www/html/app/webroot/files/user/image/35/1439985339.jpg'
  [APP/Plugin/Upload/Model/Behavior/UploadBehavior.php, line 349]</p>
  </blockquote>
  <p>and code is</p>
  <pre><code>protected function _mkPath(Model $model, $field, $destDir) {
      if (!file_exists($destDir)) {
          mkdir($destDir, $this-&gt;settings[$model-&gt;alias][$field]['mode'], true);
          chmod($destDir, $this-&gt;settings[$model-&gt;alias][$field]['mode']);
      }   
      return true;
  }
  </code></pre>
  <p>following is the plugin I am using
  <a href="http://github.com/josegonzalez/cakephp-upload" rel="nofollow noreferrer">http://github.com/josegonzalez/cakephp-upload</a></p>
  <blockquote>
  <p>should I need to give 777 permission to webroot</p>
  </blockquote>