Skip to content
Advertisement

Annotation error while trying to upload image using symfony 4.4

enter image description hereI am using Symfony 4.4 and trying to upload an image. But while creating schemas I am getting an Annotation error.

[Semantical Error] The annotation “@SymfonyComponentValidatorConstraintsImageImage” in property AppEntityStudent::$photo was never imported. Did you maybe forget to add a “use” statement for this annotation?

Attaching the code snippets below, please say what is the mistake I made.

use SymfonyComponentValidatorConstraints as Assert;

/** 
      * @AssertNotBlank(message="Please, upload the photo.") 
      * @AssertFile(mimeTypes={ "image/png", "image/jpeg" }) 
   */
    private $photo;

=====================

Advertisement

Answer

It looks like you forgot to add use SymfonyComponentValidatorConstraints as Assert; to the top of the file.

According to the error message and the documentation for NoBlank, that line should fix your issue.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement