title: PHP: "failed to open stream: Permission denied"
body: <p>I am getting some interesting results on my server when i try to access any Directory or File via some Function.I have set all my file &amp; directory permissions to 777 and have changed the content owner to Apache but i still get error messages.Code:<br />
  <code>move_uploaded_file($_FILES['file']['tmp_name'], '/var/www/html/fileContent_Site/userData/'.$_SESSION['username'].DIRECTORY_SEPARATOR.$_FILES['file']['name']);
  </code><br />
  Or
  <code>file_put_contents('userData/userData.txt', $result,FILE_APPEND);</code>
  <code>
  mkdir(&quot;userData/&quot;.$register['username']);</code></p>
  <p>For 'move_uploaded_file()' i get:</p>
  <blockquote>
  <p>move_uploaded_file(/var/www/php/Site/userData/radi/110729.png):failed to open stream: Permission denied in /var/www/php/Site/upload.php</p>
  <blockquote>
  <p>move_uploaded_file(): Unable to move '/tmp/phpUFvMcn' to '/var/www/php/Site/userData/radi/110729.png' in /var/www/php/Site/upload.php</p>
  </blockquote>
  </blockquote>
  <p>And for 'file_put_content()' and 'mkdir()'</p>
  <blockquote>
  <p>file_put_contents(userData/userData.txt): failed to open stream: Permission denied in /var/www/php/Site/register.php</p>
  <p>mkdir(): Permission denied in /var/www/php/Site/register.php</p>
  </blockquote>