Skip to content
Advertisement

How to use Vich uploader with easyAdmin 3 on Symfony 5

I’ve been trying to use VichUploader to upload files on a Symfony project, already using EasyAdmin 3.

I’ve configured everything correctly, but I’m getting this error:

The “pieceJointeFile” image field must define the directory where the images are uploaded using the setUploadDir() method.

JavaScript

vich uploader configuration

JavaScript

and finally My crud controller

JavaScript

Finally, I want to clarify that when using TextField it works correctly.

Advertisement

Answer

You can solve this problem by creating a simple field class

JavaScript

And then use it in your crud controllers

JavaScript

Two times here because you need image field to render and imageFile on forms

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