title: Problems with PHP upload and setting file attributes
body: <p>I am currently trying to add an upload system where a user can upload their own file. They will be able to:</p>
  
  <ul>
  <li>Name it</li>
  <li>Categorize It</li>
  <li>Add a Description</li>
  <li>Add Instructions for it's use</li>
  <li>Add a thumbnail for it</li>
  </ul>
  
  <p>I have begun by just adding the ability to name it, however I have stumbled at the first stage!</p>
  
  <p>I have very limited knowledge of PHP (I'm a static HTML guy), so I tried to accomplish my goal through the help of others and online tutorials. Find my code sample below.</p>
  
  <p><a href="http://www.vexnet.org/cubeworld/addamod.html" rel="nofollow">Here is a link to the live development site »</a> Hopefully the site will help you to see what I want to do and what goes wrong!</p>
  
  <pre><code>if ($_FILES["mod-name"]["error"] &gt; 0)
    {
    echo "Error: " . $_FILES["mod-name"]["error"] . "&lt;br&gt;";
    }
  else
    {
    echo "Upload: " . $_FILES["mod-name"]["name"] . "&lt;br&gt;";
    echo "Type: " . $_FILES["mod-name"]["type"] . "&lt;br&gt;";
    echo "Size: " . ($_FILES["mod-name"]["size"] / 1024) . " kB&lt;br&gt;";
    echo "Stored in: " . $_FILES["mod-name"]["tmp_name"];
    }
  ?&gt;
  
  &lt;?php
  $allowedExts = array("gif", "jpeg", "jpg", "png");
  $temp = explode(".", $_FILES["mod-name"]["name"]);
  $extension = end($temp);
  if ((($_FILES["mod-name"]["type"] == "image/gif")
  || ($_FILES["mod-name"]["type"] == "image/jpeg")
  || ($_FILES["mod-name"]["type"] == "image/jpg")
  || ($_FILES["mod-name"]["type"] == "image/pjpeg")
  || ($_FILES["mod-name"]["type"] == "image/x-png")
  || ($_FILES["mod-name"]["type"] == "image/png"))
  &amp;&amp; ($_FILES["mod-name"]["size"] &lt; 500000)
  &amp;&amp; in_array($extension, $allowedExts))
    {
    if ($_FILES["mod-name"]["error"] &gt; 0)
      {
      echo "Error: " . $_FILES["mod-name"]["error"] . "&lt;br&gt;";
      }
    else
      {
      echo "Upload: " . $_FILES["mod-name"]["name"] . "&lt;br&gt;";
      echo "Type: " . $_FILES["mod-name"]["type"] . "&lt;br&gt;";
      echo "Size: " . ($_FILES["mod-name"]["size"] / 1024) . " kB&lt;br&gt;";
      echo "Stored in: " . $_FILES["mod-name"]["tmp_name"];
      }
    }
  else
    {
    echo "Invalid file";
    }
  ?&gt;
  
  &lt;?php
  $allowedExts = array("gif", "jpeg", "jpg", "png");
  $temp = explode(".", $_FILES["mod-name"]["name"]);
  $extension = end($temp);
  if ((($_FILES["mod-name"]["type"] == "text/plain"))
  &amp;&amp; ($_FILES["mod-name"]["size"] &lt; 20000)
  &amp;&amp; in_array($extension, $allowedExts))
    {
    if ($_FILES["mod-name"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["mod-name"]["error"] . "&lt;br&gt;";
      }
    else
      {
      echo "Upload: " . $_FILES["mod-name"]["name"] . "&lt;br&gt;";
      echo "Type: " . $_FILES["mod-name"]["type"] . "&lt;br&gt;";
      echo "Size: " . ($_FILES["mod-name"]["size"] / 1024) . " kB&lt;br&gt;";
      echo "Temp file: " . $_FILES["mod-name"]["tmp_name"] . "&lt;br&gt;";
  
      if (file_exists("/mod/" . $_FILES["mod-name"]["name"]))
        {
        echo $_FILES["mod-name"]["name"] . " already exists. ";
        }
      else
        {
        move_uploaded_file($_FILES["mod-name"]["tmp_name"],
        "upload/" . $_FILES["mod-name"]["name"]);
        echo "Stored in: " . "/mod/" . $_FILES["mod-name"]["name"];
        }
      }
    }
  else
    {
    echo "Invalid file";
    }
  </code></pre>
  
  <p>My HTML:</p>
  
  <pre><code>&lt;form method="post" action="upload_file.php" enctype='multipart/form-data'&gt;
    &lt;fieldset&gt;
      &lt;legend&gt;Please fill in every field below!&lt;/legend&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="ModName"&gt;Mod Name&lt;/label&gt;
        &lt;input type="text" class="form-control" id="mod-name" placeholder="Enter the mod's name"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="ModDesc"&gt;Description&lt;/label&gt;
              &lt;textarea type="text" class="form-control" id="mod-desc" placeholder="Write a little bit about your mod..." rows="4"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="ModInstall"&gt;How to install your Mod:&lt;/label&gt;
        &lt;textarea type="text" class="form-control" id="mod-install" placeholder="Help us know how to use your mod!" rows="3"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="ModThumb"&gt;Add thumbnail&lt;/label&gt;
        &lt;input type="file" id="mod-thumb"&gt;
        &lt;p class="help-block"&gt;Max file size of image: 300kb&lt;/p&gt;
      &lt;/div&gt;
      Select the Category(s) that your mod falls under:&lt;br /&gt; 
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; Client Mod
        &lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; Game Tweak
        &lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; .CUB Model
        &lt;/label&gt;
      &lt;/div&gt;&lt;br /&gt;
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; Server Mod
        &lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; Web Tool
        &lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="checkbox-inline"&gt;
        &lt;label&gt;
          &lt;input type="checkbox"&gt; Map Editior
        &lt;/label&gt;
      &lt;/div&gt;
      &lt;hr /&gt;
  
      &lt;div class="form-group"&gt;
        &lt;label for="ModThumb"&gt;Upload your Mod!&lt;/label&gt;
        &lt;input type="file" id="mod"&gt;
        &lt;p class="help-block"&gt;Max file size: 5MB (sorry)&lt;/p&gt;
      &lt;/div&gt;
      &lt;button type="submit" class="btn-lg btn-success"&gt;Add it to the Database!&lt;/button&gt;
    &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>