title: failed to open stream and permission denied errors
body: <p>I've been stuck on two problems and I think they are related. The first is that I'm trying to upload a file (and I intend to rename after I get this to work). The second is I'm trying to log certain events. </p>
  
  <p>The code to the first issue is:</p>
  
  <pre><code>move_uploaded_file($_FILES['logo']['tmp_name'], 
  basename($_FILES['logo']['name']));
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>Warning:  move_uploaded_file(224537_10150405406507786_833667785_10758194_3953892_n.jpg): 
  failed to open stream: Permission denied in /var/www/html/MVP/test/uploadFile.php 
  on line 3 Warning: move_uploaded_file(): Unable to move '/tmp/phpuDHoo6' 
  to '224537_10150405406507786_833667785_10758194_3953892_n.jpg' 
  in /var/www/html/MVP/test/uploadFile.php on line 3
  </code></pre>
  
  <p>The second code to the second problem looks like this:</p>
  
  <pre><code>function logToFile($msg){
    $logfile=dirname(__FILE__)."/../../shared/log/logCleanups.log";
    $fd = fopen($logfile, "a+");
    fwrite($fd, date("Y-m-d H:i:s",time("now")).$msg."/n");
    fclose($fd);
  }
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>Warning: fopen(/var/www/html/MVP/administrative/controllers/../../shared/log/logCleanups.log): 
  failed to open stream: No such file or directory 
  in /var/www/html/MVP/administrative/controllers/cleanupAds.php 
  on line 10 
  Warning: fclose() expects parameter 1 to be resource, boolean given 
  in /var/www/html/MVP/administrative/controllers/cleanupAds.php on line 12 
  </code></pre>
  
  <p>Oh. And, I already did the chmod 777 thing. It seems like every answer I've found is that.</p>