title: PHP file upload to directory based upon unique user id
body: <p>I can't seem to get the directory to take the user <strong>id variable ($id)</strong> in the file path. Uploading straight into the member folder is no issue, but once I try for the unique folder created based upon user id during registration, I am roadblocked.</p>
  
  <p>Here is what I've pieced together thus far:</p>
  
  <pre><code>&lt;?php
  $id = $_SESSION['id'];
  $udir= "members/.$id./";
  $ufile = $udir . basename($_FILES['file']['name']);
  $allexts = array("jpg", "jpeg", "gif", "png");
  $ext = end(explode(".", $_FILES["file"]["name"]));
  if ((($_FILES["file"]["type"] == "image/gif")
      || ($_FILES["file"]["type"] == "image/jpeg")
      || ($_FILES["file"]["type"] == "image/pjpeg")
      || ($_FILES["file"]["type"] == "image/png"))
      &amp;&amp; ($_FILES["file"]["size"] &lt; 2000000)
      &amp;&amp; in_array($ext, $allexts)){
      if (move_uploaded_file($_FILES['file']['tmp_name'], $ufile)) {
          echo "File upload was successful.";
      } else {
          echo "An error has occured. Please try again.";
      }
  } else {
      echo "Invalid file type. Please try again.";
  } ?&gt;
  </code></pre>