title: Upload file outside web root directory
body: <p>i want to upload images outside web root directory, but i don't know how to do it. <br>
  For example i want to put images in <strong>var/media3/</strong>, i set the media directory to permissions 777, now i need to modify the code to put images because that can not work.<br>
  I tryed even using <code>$_SERVER['DOCUMENT_ROOT']</code> but it doesn't work (and honestly I have never tried this kind of thing).
  <br><br>
  This is the upload.php script:</p>
  
  <pre><code>&lt;?php
  
  // A list of permitted file extensions
  $allowed = array('png', 'jpg', 'gif');
  
  if(isset($_FILES['upl']) &amp;&amp; $_FILES['upl']['error'] == 0){
  
      $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
  
      if(!in_array(strtolower($extension), $allowed)){
          echo '{"status":"error"}';
          exit;
      }
  
      if(move_uploaded_file($_FILES['upl']['tmp_name'], 'var/media3/'.$_FILES['upl']['name'])){ // &lt;--The problem is in this string, it won't work
          echo '{"status":"success"}';
          exit;
      }
  }
  
  echo '{"status":"error"}';
  exit;
  </code></pre>
  
  <p><br>
  <br>
  Thanks XD</p>