title: Allowing users to upload files through website | PHP
body: <p>Ok so I followed a <a href="http://www.tizag.com/phpT/fileupload.php" rel="nofollow">tutorial</a> that taught me how to build a simple upload system on my website. Well I'm getting errors instead... </p>
  
  <p>I have a form that allows the user to select the file they want to upload: </p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="studentAccess/files/uploader.php" method="POST"&gt;
  
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt;
  
      Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt;
  
      &lt;input type="submit" value="Upload File" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>And this PHP script that is supposed to do all the work. Now I am slightly confused on the tutorial, I'm not sure if this script should be split into two different files or be in the same file as it is right now. </p>
  
  <pre><code>&lt;?php
  
  // Where the file is going to be placed 
  $target_path = "/studentAccess/uploads/";
  
  /* Add the original filename to our target path.  
  Result is "uploads/filename.extension" */
  $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
  
  $target_path = "/studentAccess/uploads/";
  
  $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>The script above is placed inside the <code>Files</code> folder which is inside studentAccess </p>
  
  <p>The folder I am wanting to store the uploaded file is inside studentAccess and called <code>uploads</code></p>
  
  <pre><code>studentAccess
    |
    | files 
    | |
    | | uploader.php *this is where the script is located to upload file*
    | |
    | uploads
    | |
    | | *this is the folder where I want to store the uploaded files*
    | |
  </code></pre>
  
  <p>Above is the folder layout of where everything is located. The reason I'm including this is because I'm not sure if it is laid out correctly. Does the <code>uploader.php</code> file need to be in the same folder the uploads are stored?  </p>
  
  <p>When I run the script (i.e. Upload a file using the form and hitting Upload File button) I receive three errors displayed directly in the browser window. </p>
  
  <p><code>Warning: move_uploaded_file(/studentAccess/uploads/NHSHandbook1314.doc) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/www/usd309bands.org/studentAccess/files/uploader.php on line 14</code></p>
  
  <p><code>Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpRpP6uz' to '/studentAccess/uploads/NHSHandbook1314.doc' in /home/www/usd309bands.org/studentAccess/files/uploader.php on line 14</code></p>
  
  <p>And finally the error that is generated by the script itself</p>
  
  <p><code>There was an error uploading the file, please try again!</code></p>
  
  <p>So I am really not sure what I am doing wrong, It appears to me that it is having problems moving the uploaded file to the uploads folder. But I'm really not sure what I need to do to fix the problem. <strong>I did check and <code>file_uploads</code> is turned on within my server.</strong></p>
  
  <p>I hope I have described my question in detail enough to get help. I hope it was laid out in a readable format. I am really needing some help.</p>