title: Serialization of UploadedFile is not allowed
body: <p>I'm trying to upload a file via <a href="https://github.com/dustin10/VichUploaderBundle" rel="nofollow noreferrer" >vichuploader bundle</a> on my Users entity.
  Using <a href="https://github.com/hwi/HWIOAuthBundle" rel="nofollow noreferrer" >hwioauthbundle</a> that implements UserInterface, and i think the errors comes from that bundle...
  So  every time i try to uplod a file i got this exception :</p>
  
  <blockquote>
    <p>Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile'
    is not allowed</p>
  </blockquote>
  
  <p>I already tried <a href="https://stackoverflow.com/questions/23512381/serialization-of-symfony-component-httpfoundation-file-uploadedfile-is-not-all" > this solution</a> but also same exception.
      
  
  <pre><code>namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
  use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseClass;
  use Symfony\Component\Security\Core\User\UserInterface;
  use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthUser;
  
  
  /**
   * Users 
   * @ORM\Table(name="users")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\UsersRepository")
   *
   */
  class Users extends  OAuthUser 
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="first_name", type="string", length=255)
       */
      private $firstName;
  
      /**
       * @var string
       *
       * @ORM\Column(name="last_name", type="string", length=255)
       */
      private $lastName;
  
      /**
       * @var string
       *
       * @ORM\Column(name="civility", type="string", length=255, nullable=true)
       */
      private $civility;
      /**
       * @var string
       *
       * @ORM\Column(name="avatar", type="string", length=255, nullable=true)
       */
      private $avatar;
      /**
       * @var string
       *
       * @ORM\Column(name="qualification", type="string", length=255, nullable=true)
       */
      private $qualification;
  
      /**
       * @var string
       *
       * @ORM\Column(name="level", type="string", length=255, nullable=true)
       */
      private $level;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="birth_date", type="date", nullable=true)
       */
      private $birthDate;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="hiring_date", type="date", nullable=true)
       */
      private $hiringDate;
  
      /**
       * @var string
       *
       * @ORM\Column(name="country", type="string", length=255, nullable=true)
       */
      private $country;
  
      /**
       * @var string
       *
       * @ORM\Column(name="city", type="string", length=255, nullable=true)
       */
      private $city;
  
      /**
       * @var string
       *
       * @ORM\Column(name="linkedin_profil", type="string", length=255, nullable=true)
       */
      private $linkedinProfil;
  
      /**
       * @var string
       *
       * @ORM\Column(name="web_site", type="string", length=255, nullable=true)
       */
      private $webSite;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="date_last_cnx", type="datetimetz", nullable=true)
       */
      private $dateLastCnx;
  
  
      /**
       * 
       * @ORM\OneToOne(targetEntity="AppBundle\Entity\Files",cascade={"persist"})
       * @ORM\JoinColumn(name="file_id", referencedColumnName="id")
       */
      public $cv;
  
      /** @ORM\Column(name="google_id", type="string", length=255, nullable=true) */
      private $google_id;
  </code></pre>
  
  <p>Files.php</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\HttpFoundation\File\File;
  use Vich\UploaderBundle\Mapping\Annotation as Vich;
  
  /**
   * Files
   * @Vich\Uploadable
   * @ORM\Table(name="files")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\FilesRepository")
   */
  class Files 
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
          /**
       * NOTE: This is not a mapped field of entity metadata, just a simple property.
       * 
       * @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName", size="imageSize")
       * 
       * @var File
       */
      protected $imageFile;
  
      /**
       * @ORM\Column(type="string", length=255)
       *
       * @var string
       */
      protected $imageName;
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
  
  
  
  
      /**
       * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
       * of 'UploadedFile' is injected into this setter to trigger the  update. If this
       * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
       * must be able to accept an instance of 'File' as the bundle will inject one here
       * during Doctrine hydration.
       *
       * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
       *
       * @return Product
       */
      public function setImageFile(File $image = null)
      {
          $this-&gt;imageFile = $image;
  
          if ($image) {
              // It is required that at least one field changes if you are using doctrine
              // otherwise the event listeners won't be called and the file is lost
              $this-&gt;updatedAt = new \DateTimeImmutable();
          }
  
          return $this;
      }
  
      /**
       * @return File|null
       */
      public function getImageFile()
      {
          return $this-&gt;imageFile;
      }
  
      /**
       * @param string $imageName
       *
       * @return Product
       */
      public function setImageName($imageName)
      {
          $this-&gt;imageName = $imageName;
  
          return $this;
      }
  
      /**
       * @return string|null
       */
      public function getImageName()
      {
          return $this-&gt;imageName;
      }
  
  
  }
  </code></pre>
  
  <p>My form Userstype:</p>
  
  <pre><code>use AppBundle\Form\FilesType;
  
  
  -&gt;add('cv',FilesType::class)
  </code></pre>
  
  <p>My form Filestype:</p>
  
  <pre><code> -&gt; add('imageFile',
  
   VichFileType::class, [
              'required' =&gt; false,
              'allow_delete' =&gt; true, 
              'download_link' =&gt; true,
              'label' =&gt; false, 
  
          ]);
  </code></pre>