title: Symfony3 wont convert file to UploadedFile
body: <p>I'm following this tutorial <a href="http://symfony.com/doc/current/controller/upload_file.html" rel="nofollow noreferrer">http://symfony.com/doc/current/controller/upload_file.html</a> but the $file isn't being converted to an UploadedFile, it stays as a string:</p>
  <pre><code>var_dump($file);
  /home/owner/Desktop/Workspace/Documentary/src/DW/DocumentaryBundle/Controller/Admin/DocumentaryController.php:103:string '/tmp/phpmmv1LP' (length=14)
  </code></pre>
  <blockquote>
  <p>Type error: Argument 1 passed to DW\DocumentaryBundle\Uploader\PosterUploader::upload() must be an instance of Symfony\Component\HttpFoundation\File\UploadedFile, string given, called in /home/owner/Desktop/Workspace/DocumentaryWIRE/src/DW/DocumentaryBundle/Controller/Admin/DocumentaryController.php on line 106</p>
  </blockquote>
  <p>Create Action:</p>
  <pre><code>     /**
       * @param Request $request
       * @return Response
       */
      public function createAction(Request $request)
      {
          $documentary = new Documentary();
  
          $form = $this-&gt;createForm(DocumentaryType::class, $documentary);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $file = $documentary-&gt;getPoster();
  
              $posterUploader = $this-&gt;getPosterUploader();
              $fileName = $posterUploader-&gt;upload($file);
  
              $documentary-&gt;setPoster($fileName);
  
              $documentaryService = $this-&gt;getDocumentaryService();
              $documentaryService-&gt;save($documentary);
          }
  
          return $this-&gt;render('DocumentaryBundle:Admin:create.html.twig', array(
              'form' =&gt; $form-&gt;createView(),
          ));
      }
  </code></pre>
  <p>View</p>
  <pre><code>{{ form_start(form) }}
  {{ form_widget(form) }}
  {{ form_end(form) }}
  </code></pre>
  <p>Form:</p>
  <pre><code>&lt;?php
  
  namespace DW\DocumentaryBundle\Form;
  
  use DW\DocumentaryBundle\Entity\Documentary;
  use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\FileType;
  use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class DocumentaryType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('title', TextType::class)
              -&gt;add('storyline', TextareaType::class)
              -&gt;add('summary', TextareaType::class)
              -&gt;add('year', IntegerType::class)
              -&gt;add('length', IntegerType::class)
              -&gt;add('status', TextType::class)
              -&gt;add('views', IntegerType::class)
              -&gt;add('shortUrl', TextType::class)
              -&gt;add('videoId', TextType::class)
              -&gt;add('videoSource', TextType::class)
              -&gt;add('poster', FileType::class, [
                  'label' =&gt; 'Poster'])
              -&gt;add('category', EntityType::class, [
                  'class' =&gt; 'CategoryBundle:Category',
                  'choice_label' =&gt; 'name',
              ])
              -&gt;add('submit', SubmitType::class);
      }
  
      /**
       * @param OptionsResolver $resolver
       */
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; Documentary::class,
          ));
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return &quot;documentary&quot;;
      }
  }
  </code></pre>
  <p>Controller:</p>
  <pre><code>&lt;?php
  
  namespace DW\DocumentaryBundle\Uploader;
  
  use Symfony\Component\HttpFoundation\File\UploadedFile;
  
  class PosterUploader
  {
      /**
       * @var string
       */
      private $targetDir;
  
      /**
       * @param string $targetDir
       */
      public function __construct(string $targetDir)
      {
          $this-&gt;targetDir = $targetDir;
      }
  
      /**
       * @param UploadedFile $file
       * @return string
       */
      public function upload(UploadedFile $file)
      {
          $fileName = md5(uniqid()).'.'.$file-&gt;guessExtension();
  
          $file-&gt;move($this-&gt;targetDir, $fileName);
  
          return $fileName;
      }
  }
  </code></pre>