title: PHP move_uploaded_file failing
body: <p>I have a form that is sending user input to a MySQL database. It should also be sending a file from a file upload to a directory on my server. Everything in it is working good, other than the file upload part. I am a PHP newbie, so I am obviously just failing in my PHP code. Any advice would be much appreciated. </p>
  
  <h1>questCreate.php:</h1>
  
  <pre><code>&lt;form name="quest" action="questSave.php" method="post"&gt;
  
  &lt;h1&gt; Create a Quest &lt;/h1&gt;
  
  &lt;!!!---QUEST BASICS---!!!&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
           &lt;td align="center"&gt;&lt;b&gt;Quest Basics&lt;/b&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="right"&gt;Quest:&lt;/td&gt;
          &lt;td&gt; 
          &lt;input type="text" name="questName" size="30" placeholder="Quest Name" onfocus="this.placeholder = ''" onblur="this.placeholder='Quest Name'"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="right"&gt;Creator:&lt;/td&gt;
          &lt;td&gt;
          &lt;input type="text" name="creator" size="30"  placeholder="Player Name" onfocus="this.placeholder = ''" onblur="this.placeholder='Player Name'"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="right"&gt;Campaign Setting:&lt;/td&gt;
          &lt;td&gt;
          &lt;select name="setting" size="1" onchange="Set_Setting()"&gt;
              &lt;option&gt; D&amp;D Generic Setting&lt;/option&gt;
              &lt;option&gt; Eberron&lt;/option&gt;
              &lt;option&gt; Forgotten Realms&lt;/option&gt;
              &lt;option&gt; Greyhawk&lt;/option&gt;
              &lt;option&gt; Ravenloft&lt;/option&gt;
          &lt;/select&gt;
           &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="right"&gt; Map upload:&lt;/td&gt;
          &lt;td&gt;
              &lt;input type="file" id="map" name="map"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;br&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;!!!---PLAYER ALLOTTMENTS---!!!&gt;
  
  &lt;tr&gt;
       &lt;td align="center"&gt;&lt;b&gt;Player Allottments&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td align="right"&gt;Total Quest Experience:&lt;/td&gt;
      &lt;td&gt;
          &lt;input type="number" name="experience" size="30"  placeholder="100"&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td align="right"&gt;Items/Weapons:&lt;/td&gt;
      &lt;td&gt;
          &lt;textarea name="items_weapons" cols="30" rows="5"  placeholder="Earnable Items and Weapons" onfocus="this.placeholder = ''" onblur="this.placeholder='Earnable Items and Weapons'" style="resize: none;"&gt;&lt;/textarea&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td align="right"&gt;Save Quest:&lt;/td&gt;
      &lt;td&gt;
          &lt;input type="submit"&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/form&gt;
  &lt;/table&gt;
  &lt;/center&gt;
  </code></pre>
  
  <h1>questSave.php:</h1>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("localhost","username","password","db");
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  $sql="INSERT INTO quests (questName, creator, setting, experience, items_weapons)
  VALUES    ('$_POST[questName]','$_POST[creator]','$_POST[setting]','$_POST[experience]','$_POST[items_weapons]')";
  
  $target_path = "maps/";
  
  $target_path = $target_path . basename( $_FILES['map']['name']); 
  
  if(move_uploaded_file($_FILES['map']['tmp_name'], $target_path)) {
      echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
      " has been uploaded";
  } else{
      echo "There was an error uploading the file, please try again!";
  }
  
  if (!mysqli_query($con,$sql))
    {
    die('Error: ' . mysqli_error($con));
    }
  
  header("Location: questList.php");
  die();
  
  mysqli_close($con);
  ?&gt;
  </code></pre>