title: File Upload Issue with PHP Undefined Index
body: <p>This question has been asked numerous times, especially here on the forums but each one is specific to each users situation so none have seemed to help.</p>
  
  <p>I am using the basic <a href="http://www.w3schools.com/php/php_file_upload.asp" rel="nofollow">how to from w3schools</a> but cannot seem to get this working.. I get the error Undefined Index: file, but nothing looks wrong in my code or validation file.  Can someone help?</p>
  
  <p>HTML Form:</p>
  
  <pre><code>&lt;form role="form" method="GET" action="&lt;?php echo $processUrl; ?&gt;" enctype="multipart/form-data"&gt;
  
            &lt;div class="form-group col-md-6 col-sm-12"&gt;
              &lt;label for="GmailID"&gt;Gmail Email Address&lt;/label&gt;&lt;input type="email" id="GmailID" name="GmailID" class="form-control" placeholder="Example@gmail.com" /&gt;
            &lt;/div&gt;
  
            &lt;div class="form-group col-md-6 col-sm-12"&gt;
              &lt;label for="GmailPW"&gt;Gmail Password&lt;/label&gt;&lt;input type="password" id="GmailPW" name="GmailPW" class="form-control" placeholder="Gmail Password" /&gt;
            &lt;/div&gt;
  
            &lt;div class="form-group col-md-6 col-sm-12"&gt;
              &lt;label for="WebmailID"&gt;Webmail Email Address&lt;/label&gt;&lt;input type="email" id="WebmailID" name="WebmailID" class="form-control" placeholder="Example@example.com" /&gt;
            &lt;/div&gt;
  
            &lt;div class="form-group col-md-6 col-sm-12"&gt;
              &lt;label for="WebmailPW"&gt;Webmail Password&lt;/label&gt;&lt;input type="password" id="WebmailPW" name="WebmailPW" class="form-control" placeholder="Password" /&gt;
            &lt;/div&gt;
  
            &lt;div class="form-group col-md-6 col-sm-12"&gt;
              &lt;input type="hidden" name="MAX_FILE_SIZE" value="&lt;?php echo $max_file_size ?&gt;" /&gt;
              &lt;label for="file"&gt;Profile Picture&lt;/label&gt;&lt;input type="file" id="file" name="file" /&gt;
            &lt;/div&gt;
  
            &lt;input type="hidden" id="userID" name="userID" value="&lt;?php echo $_SESSION['user_id']; ?&gt;" /&gt;
            &lt;div class="row"&gt;
              &lt;button type="submit" class="btn btn-primary pull-right" onclick="return regformhash(this.form,
                                     this.form.GmailID,
                                     this.form.GmailPW,
                                     this.form.WebmailID,
                                     this.form.WebmailPW);"&gt;Submit&lt;/button&gt;
          &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>PHP Script:</p>
  
  <pre><code>$allowedExts = array("gif", "jpeg", "jpg", "png");
          $temp = explode(".", $_FILES["file"]["name"]);
          $extension = end($temp);
  
          if ((($_FILES["file"]["type"] == "image/gif")
          || ($_FILES["file"]["type"] == "image/jpeg")
          || ($_FILES["file"]["type"] == "image/jpg")
          || ($_FILES["file"]["type"] == "image/pjpeg")
          || ($_FILES["file"]["type"] == "image/x-png")
          || ($_FILES["file"]["type"] == "image/png"))
          &amp;&amp; ($_FILES["file"]["size"] &lt; 20000)
          &amp;&amp; in_array($extension, $allowedExts)) {
            if ($_FILES["file"]["error"] &gt; 0) {
              echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
            } else {
              echo "Upload: " . $_FILES["file"]["name"] . "&lt;br&gt;";
              echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;";
              echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;";
              echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;";
              if (file_exists("https://example.com/uploads/" . $_FILES["file"]["name"])) {
                echo $_FILES["file"]["name"] . " already exists. ";
              } else {
                move_uploaded_file($_FILES["file"]["tmp_name"],
                "https://example.com/uploads/" . $_FILES["file"]["name"]);
                echo "Stored in: " . "https://example.com/uploads/" . $_FILES["file"]["name"];
              }
            }
          } else {
            echo "Invalid file";
          }
  </code></pre>
  
  <p>Has anyone else encountered this or have a possible solution? </p>