title: Uploading a file via PHP + Symfony 4 throws an "File not found error"
body: <p>I am trying to upload a file using Symfony 4 documentation (<a href="https://symfony.com/doc/4.0/controller/upload_file.html" rel="nofollow noreferrer">https://symfony.com/doc/4.0/controller/upload_file.html</a>) - yes, I know that is an obsolete version, but at the moment I can't update it.</p>
  
  <p>I have done everything as in documentation (except for creating a new entity, because I only need to upload files, and send link to that file in email), files are uploaded correctly to my directory, but it throws HTTP 500 errors, and in log files there are something like this:</p>
  
  <blockquote>
    <p>[2020-04-20 15:39:40] request.CRITICAL: Uncaught PHP Exception Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: "The file "/tmp/phpr2tM6D" does not exist" at [...]/vendor/symfony/http-foundation/File/File.php line 37 {"exception":"[object] (Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException(code: 0): The file \"/tmp/phpr2tM6D\" does not exist at [...]/vendor/symfony/http-foundation/File/File.php:37)"} []</p>
  </blockquote>
  
  <p>any ideas?</p>
  
  <p>ok, so form is basically just</p>
  
  <pre><code>    {{ form_start(warranty_form) }}
      {{ form_end(warranty_form)}}
  </code></pre>
  
  <p>and fragments of controller</p>
  
  <pre><code>    $form = $this-&gt;createForm(WarrantyType::class);
      $form-&gt;handleRequest($request);
  
      if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
          /** @var UploadedFile $documentFile */
          $documentFile = $form-&gt;get('documentFile')-&gt;getData();
  
          if($documentFile) {
              $originalDocumentFilename = pathinfo($documentFile-&gt;getClientOriginalName(), PATHINFO_FILENAME);
              $newDocumentFilename = uniqid().'.'.$documentFile-&gt;guessExtension();
  
               try {
                  $documentFile-&gt;move('%kernel.project_dir%/public/uploads/pdf',$newDocumentFilename);
  
                } catch(FileException $e) {
  
                }
                      $message = (new \Swift_Message('Test email '))
                      -&gt;setFrom('error@example.org')
                      -&gt;setTo('error@example.org')
                      -&gt;setBody("a","text/plain");
          }   
  </code></pre>
  
  <p>and form is just a standard form, with possibility to upload PDF files</p>
  
  <pre><code>            -&gt;add('documentFile', FileType::class, ['label' =&gt; 'Dokument', 'mapped' =&gt; false, 'required' =&gt; true, 'constraints' =&gt; [new File(['maxSize' =&gt; '1024k', 'mimeTypes' =&gt; ['application/pdf', 'application/x-pdf'], 'mimeTypesMessage' =&gt; 'Załaduj prawidłowy dokument'])]])  
  </code></pre>