title: Call to a member function guessExtension() on string
body: <p>In Symfony 4 I'm getting this error:
  Call to a member function guessExtension() on string
  In previous I used same code to upload image and doing well, but here i'm getting error.
  Has anyone faced the same issue and solved?</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
      $imageEn = new Image();
  
       $form = $this-&gt;createForm(ImageUploadType::class, $imageEn);
  
       $form-&gt;handleRequest($request);
  
       if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()){
  
  
       /** @var Symfony\Component\HttpFoundation\File\UploadedFile $file */
  
          $file = $imageEn-&gt;getImage();
  
          $fileName = md5(uniqid()).'.'.$file-&gt;guessExtension();
  
          $file-&gt;move($this-&gt;getParameter('image_directory'), $fileName);
  
          $imageEn-&gt;setImage($fileName);
          $em-&gt;persist($imageEn);
          $em-&gt;flush();
  
          $this-&gt;addFlash('notice', 'Post Submitted Successfully!!!');
  
          return $this-&gt;redirectToRoute('image_upload');
       }
  </code></pre>
  
  <p>Form:</p>
  
  <pre><code>  {
      $builder
          -&gt;add('title', TextType::class)
          -&gt;add('description', TextType::class)
          -&gt;add('image', FileType::class, array('label'=&gt;'Upload Image'))
          -&gt;add('submit', SubmitType::class)
      ;
  }
  </code></pre>
  
  <p>Image Class:</p>
  
  <p>Actually I followed a tutorial where he made this class manually but I used Command to create class, I tallied all his code with mine and it was correct.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
  * @ORM\Entity(repositoryClass="App\Repository\ImageRepository")
  */
  class Image
  {
  /**
   * @ORM\Id()
   * @ORM\GeneratedValue()
   * @ORM\Column(type="integer")
   */
  private $id;
  
  /**
   * @ORM\Column(type="string", length=255)
   */
  private $title;
  
  /**
   * @ORM\Column(type="string", length=255)
   */
  private $description;
  
  /**
   * @ORM\Column(type="string", length=255)
   * @Assert\NotBlank(message="Please upload image")
   * @Assert\File(mimeTypes={"image/jpeg"})
   */
  private $image;
  
  public function getId()
  {
      return $this-&gt;id;
  }
  
  public function getTitle(): ?string
  {
      return $this-&gt;title;
  }
  
  public function setTitle(string $title): self
  {
      $this-&gt;title = $title;
  
      return $this;
  }
  
  public function getDescription(): ?string
  {
      return $this-&gt;description;
  }
  
  public function setDescription(string $description): self
  {
      $this-&gt;description = $description;
  
      return $this;
  }
  
  public function getImage(): ?string
  {
      return $this-&gt;image;
  }
  
  public function setImage(string $image): self
  {
      $this-&gt;image = $image;
  
      return $this;
  }
  </code></pre>
  
  <p>}</p>