Im trying to validate my form, it has a fileType field in it. I use asserts to validate the form. The validation works correctly for all field except the fileType field. It is only allowed to upload jpg jpeg and png files, but if I try to upload for example a PDF file it says my form is valid.
This is the code of the field holding the filename in the db
/**
* @ORM\Column(name="imgHomepage", type="string")
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"image/jpg", "image/jpeg", "image/png"},
* mimeTypesMessage = "Images must be jpg, jpeg or png"
* )
*/
private $imgHomepage = '';
This is the code of my fileType being added in the formtype of my entity
->add('imgHomepage', FileType::class, [
'mapped' => false,
'data_class' => null,
'required' => false,
'error_bubbling' => true
])
This is the code from my controller
$influencer = self::getInfluencerById($influencerId);
$influencerShowForm = self::CreateInfluencerForm($influencer);
$influencerShowForm->handleRequest($request);
if ($influencerShowForm->isSubmitted() && $influencerShowForm->isValid()) {
// handle form
}