title: Convert $_Files['userfile']['name'] to variable
body: <p>I am using code for an to upload files as seen below:</p>
  
  <pre><code>$uploaddir = "./images/";
  $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
  } else {
     echo "Upload failed";
  }
  </code></pre>
  
  <p>The code works to upload the image but I want to be able to post the filename to an SQL database afterwords.</p>
  
  <p>I need to get the filename I uploaded and make it a variable called <code>$filename</code> so i can then use:</p>
  
  <pre><code>$image = $_POST[$filename];
  </code></pre>
  
  <p>I've tried using this to make it a variable</p>
  
  <pre><code>$filename = $_FILES['userfile']['name'];
  </code></pre>
  
  <p>All I get is an error saying undefined index : image.jpg on the <code>$_POST</code> and I'm uncertain why. Its listing the image filename in the error so why cant it upload it.</p>