title: Uploading a file with twig and Slim framework (Version 2) - PHP
body: <p>I'm using UserFrosting a user management system and I'm having some trouble uploading a file through form post, this is what I tried</p>
  
  <p><strong>This is how my twig file looks.</strong></p>
  
  <pre><code>&lt;form name="eveniment" method="post" action="{{form_action}}" enctype="multipart/form-data"&gt;
    ...
    &lt;input type="file" class="form-control" name="poza" id="poza"&gt;
    ...
  &lt;/form&gt;`
  </code></pre>
  
  <p><strong>This is how my controller looks like</strong></p>
  
  <pre><code>$target_dir = "uploads/";
  $target_file = $target_dir . basename($_FILES["poza"]["name"]);
  $uploadOk = 1;
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  
  // Check if image file is a actual image or fake image
  $check = getimagesize($_FILES);
  if($check !== false) {
      $ms-&gt;addMessage("success", "File is an image - " . $check["mime"] . ".");
      $uploadOk = 1;
  } else {
      $ms-&gt;addMessage("danger", "File is not an image.");
      $uploadOk = 0;
  }
  $ms-&gt;addMessage("success", $target_file);
  // Check if file already exists
  if (file_exists($target_file)) {
      $ms-&gt;addMessage("danger", "Sorry, file already exists.");
      $uploadOk = 0;
  }
  // Check file size
  if ($_FILES["poza"]["size"] &gt; 500000) {
      $ms-&gt;addMessage("danger", "Sorry, your file is too large.");
      $uploadOk = 0;
  }
  // Check if $uploadOk is set to 0 by an error
  if ($uploadOk == 0) {
      $ms-&gt;addMessage("danger", "Sorry, your file was not uploaded.");
  // if everything is ok, try to upload file
  } else {
      if (move_uploaded_file($_FILES["poza"]["name"], $target_file)) {
          $ms-&gt;addMessage("success", "The file ". basename( $_FILES["poza"]["name"]). " has been uploaded.");
      } else {
          $ms-&gt;addMessage("danger",  "Sorry, there was an error uploading your file.");
      }
  }
  </code></pre>
  
  <p><strong>Route</strong></p>
  
  <pre><code>$app-&gt;post('/evenimente/?', function () use ($app) {
      $controller = new UF\EvenimentController($app);
      return $controller-&gt;createEveniment();
  });
  </code></pre>
  
  <p><strong>PHP configuration</strong></p>
  
  <p><code>file_uploads On</code></p>
  
  <p><code>upload_max_filesize    128M</code></p>
  
  <p>Every other input is posted succesfully, except this one with the type="file".</p>
  
  <p>I don't have any errors, I tried different ways, but with no success. Also if I print <code>$_FILES["poza"]["name"]</code> it will be empty.</p>