title: Symfony 4 - How to fix "file not found" constraint violation when updating existing entity?
body: <p>I have a Symfony 4.2 app where the user can create and update rental properties, picture included. I have a problem when updating a rental, the form can't pass validation because the pre-loaded file isn't found ("constraint violation : file not found"). 
  The new file is uploaded via an unmapped property, uploadedPicture, so there's no conflict. </p>
  
  <p>I had this problem a while ago while updating other entities, and setting the properties with a new File object worked like a charm. So I reused the same logic, but I'm still getting an error.</p>
  
  <p>Controller : </p>
  
  <pre><code>$pictureFileName = $rental-&gt;getPicture();
  $rental-&gt;setPicture(
         new File($this-&gt;getParameter('rental_directory').'/'. $pictureFileName)
         );
  
  $form = $this-&gt;createForm(RentalEditType::class, $rental);
  $form-&gt;handleRequest($request);
  if ($form-&gt;isSubmitted()) {
        // error happens here I think, but I'll give you my updating logic too
         if ($form-&gt;isValid()) {
              $uploadedFile = $rental-&gt;getUploadedPicture();
  
              if($uploadedFile != null) {
                  $pictureFileName = $this-&gt;generateUniqueFileName().'.'.$uploadedFile -&gt;guessExtension();
  
                  $uploadedFile -&gt;move(
                      $this-&gt;getParameter('rental_directory'),
                      $pictureFileName 
                  ); 
              } 
              $rental-&gt;setPicture($pictureFileName );
          }
          $this-&gt;getDoctrine()-&gt;getManager()-&gt;flush();
  
  </code></pre>
  
  <p>Rental.php</p>
  
  <pre><code>/**
       * @ORM\Column(type="string", length=255, nullable=true)
       * @Assert\File(
       *      maxSize = "1M"
       * )
       * 
       */
      private $picture;/
  
  /**
       * @Assert\File(
       *      maxSize = "1M"
       * )
       */
      private $uploadedPicture;
  
  </code></pre>
  
  <p>dump($form->getData())</p>
  
  <pre><code>...
  -picture: File {#215 ▼
      path: "assets/uploads/rentals" // right path
      filename: "6040e7ca7792be299ce5b72da6339596.jpg" // right filename
      basename: "6040e7ca7792be299ce5b72da6339596.jpg"
      pathname: "assets/uploads/rentals/6040e7ca7792be299ce5b72da6339596.jpg"
      extension: "jpg"
      realPath: "/home/ubuntu/workspace/website/public/assets/uploads/rentals/6040e7ca7792be299ce5b72da6339596.jpg"
      aTime: 2019-06-22 20:58:36
      mTime: 2019-06-22 20:55:57
      cTime: 2019-06-22 20:55:57
      inode: 1070
      size: 724226
      perms: 0100644
      owner: 1000
      group: 1000
      type: "file"
      writable: true
      readable: true
      executable: false
      file: true
      dir: false
      link: false
    }
  ...
  </code></pre>
  
  <p>Strange thing is, when I dump form data, the File is found, it gives me a File object and not a string (the path that I registered in the database) which is what I want, but it doesn't seem to work properly since it can't pass validation. The given path seems right too, and the file exists. All the dumps return what should be expected, files, paths... so why am I getting this error 
   and how can I fix it ?</p>
  
  <p>Thanks !</p>