title: Notice: Undefined index: ($_FILES)
body: <p>There are multiple questions[duplicates] about this same error but I can't find a solution in any of them. I`m trying to save an image in my local directory but 'Undefined index' keeps showing up. I´m a noob in php and stack overflow. I would really appreciate any of your help. </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form method="post" action="process.php" enctype="multipart/form-data"&gt;
    &lt;fieldset&gt;
      &lt;div class="col-xs-12 col-sm-push-5 image-div form-control"&gt;
        &lt;div class="input-margin"&gt;
          &lt;input type="file" name="imagenIngreso" class="filestyle" onchange="readURL(this);" data-buttonText="Subir Imagen" data-buttonName="btn-primary" data-size="nr" data-buttonBefore="false"&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;img class="image-preview" id="blah" src=""/&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="col-xs-12 col-sm-12 submit-button"&gt;
        &lt;button type="submit" class="btn btn-primary btn-block" name="submit" value="ingreso"&gt;Ingresar&lt;/button&gt;
      &lt;/div&gt;
    &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP: </p>
  
  <pre><code> // Previous Validations
   else if($_POST['submit'] == 'ingreso') {
      $fileName = $_FILES['imagenIngreso']['name']; // Line throwing error
      $uploadDirectory = "images/uploadedImages/Ingresos/";
      if($uploadedFileName!='') {
        $targetPath=time().$uploadedFileName;
        if(move_uploaded_file($_FILES['imagenIngreso']['tmp_name'], $uploadDirectory.$targetPath)) {    
          $queryIngresos = "INSERT INTO ingresos (fechaIngreso, responsable, proyecto, items, imagePath) VALUES (STR_TO_DATE('$fechaEgreso','%d/%m/%Y'), '$responsable', '$proyectoIngreso', '$itemsArray', '$targetPath')"; 
          if(!mysqli_query($con, $queryEgresos)) {
            echo "Error while uploading file";
            die('Error :'.mysqli_error($con));
          } else {
            echo 'Upload done';
            exit();
          }
  
        }
  
      }
  </code></pre>