title: How do I get the filename from a form in php? $_FILES["filename"]["name"] doesn't seem to work
body: <p>I have a form below which I'm trying to use to extract some details into a mySQL database. However, upon trying to retrieve the file in the form, everything always comes up as null. I'm not so sure why this is happening, so any help would be greatly appreciated!</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form method="post" action="myfile.php" enctype="multipart/form-data"&gt;
    &lt;table class="form-table"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Document (Optional)&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;
          &lt;select name="d" class="form-control input input-sm"&gt;
            &lt;option value="companyDoc"&gt;Company Registration Form&lt;/option&gt;
            &lt;option value="businessCard"&gt;Business Card&lt;/option&gt;               
          &lt;/select&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Upload Document (Optional)&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input type="file" class="form-control input input-sm" id="ud" name="ud"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input type="submit" value="Submit" name="submit" class="btn btn-primary pull-right"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Now my php snippet is below, where I try and call the results of the form, in the same file as the html.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>if(isset($_POST['submit'])) 
  {
    $target_dir = "../../public_html/clientarea/docs/";
    $fileName = basename($_FILES["ud"]["name"]);
    $target_file = $target_dir . $fileName;
    if($fileName!="") {
      $uploadOk = 1;
      $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
      $errorMsg = "";
      if (file_exists($target_file)) {
        $errorMsg = "Some file already exists. ";
        $uploadOk = 0;
      } else {
        if (move_uploaded_file($_FILES["ud"]["tmp_name"], $target_file)) {
            $errorMsg = "The file ". basename( $_FILES["ud"]["name"]). " has been uploaded. ";
        } else {
            $errorMsg = "There was an error uploading your some of the file.";
        }
      }
    }    
  }</code></pre>
  </div>
  </div>
  </p>