title: Why is PHP's move_uploaded_file() method returning false in my script?
body: <p>I'm building a page that allows files to be uploaded to the server, and sorted. I know this code, even if it was working, isn't fit to be live, it was just a first draft to get the mechanics working since I'm quite new to server-side scripting.  </p>
  
  <p>Anyway, here's the upload-form page: </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;?php include("header.php"); ?&gt;
  &lt;center&gt;
  &lt;h1&gt;Please enter the details of the file you would like to upload:&lt;/h1&gt;&lt;br/&gt; 
  
  
      &lt;table&gt; 
      &lt;tr&gt;
      &lt;td align='center'&gt; 
      &lt;form action='uploader.php' method='POST' enctype='multipart/form-data'&gt;&lt;b&gt;Name:&lt;/b&gt; &lt;/td&gt; 
      &lt;td align='left'&gt;&lt;input type='text' name='name' maxlength='255' /&gt;
      &lt;/td&gt;
      &lt;/tr&gt; 
  
      &lt;tr&gt;
      &lt;td align='center'&gt;&lt;b&gt;Description of file uploaded: &lt;/b&gt;
      &lt;/td&gt; 
      &lt;td align='left'&gt;&lt;textarea name='description' rows='5' cols='20'&gt;&lt;/textarea&gt;
      &lt;/td&gt;
      &lt;/tr&gt; 
  
      &lt;tr&gt;
      &lt;td align='center'&gt;&lt;b&gt;Category: &lt;/b&gt;
      &lt;/td&gt; 
  
      &lt;td align='left'&gt; 
      &lt;select name='category'&gt; 
      &lt;option value='1'&gt;Agriculture&lt;/option&gt;
      &lt;option value='2'&gt;Sexual Health&lt;/option&gt;
      &lt;option value='3'&gt;Arithmetic&lt;/option&gt;
      &lt;option value='4'&gt;Technology&lt;/option&gt;
      &lt;option value='5'&gt;Reading/Literature&lt;/option&gt;
      &lt;option value='6'&gt;Health/Medicine&lt;/option&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td align ='center' &gt;
      &lt;b&gt;File: &lt;/b&gt;
      &lt;/td&gt;
      &lt;td align='left'&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt;
      &lt;Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr height='20px'&gt;&lt;/tr&gt; 
  
      &lt;tr align ='left'&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;
      &lt;input type='Submit' value='Upload File' /&gt; 
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt; 
  
  &lt;/center&gt;
  
  &lt;?php include("footer.php"); ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and here's the action page uploader.php: </p>
  
  <pre><code>&lt;?php
  
  $target_path = "./audio/";
  
  $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
  
  if(move_uploaded_file( $_FILES['uploadedfile']['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!";
  }
  
  ?&gt;
  </code></pre>
  
  <p>Whenever I try to test this, on my localhost ( using XAMPP ) It echos "There was an error uploading the file, please try again!" </p>
  
  <p>And every few times it also says: " 
  Notice: Undefined index: uploadedfile in C:\Users\Paul\Desktop\XAMPP\htdocs\xampp\uploader.php on line 5 "</p>
  
  <p>But I can't see what's wrong with that argument? isn't uploadedfile defined as the temporary name for the file in my form? </p>
  
  <p>Can you tell me what I've done wrong here? </p>
  
  <p>Thanks a lot for </p>