I can't upload an image from EasyAdmin V3, I also added VichUpload. I must write setUploadDir() otherwise I have this error message:
and if I put this method I have this message:
in the meantime I am commenting on lines 161 to 163 vendor\easycorp\easyadmin-bundle\src\Form\Type\FileUploadType.php
but I don't want to write in vendors... Do you have an idea for uploading images in EasyAdminV3? I deleted the vich bundle while waiting for a response. Here is my CRUD Controller:
<?php
namespace App\Controller\Admin;
use App\Entity\Planches;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField as ImageFields;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\SlugField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
class PlanchesCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Planches::class;
}
public function configureFields(string $pageName): iterable
{
return [
TextField::new('name'),
SlugField::new('slug')->setTargetFieldName('name'),
ImageFields::new('illustration')
->setBasePath(' uploads/')
->setUploadDir('public/uploads')
->setUploadedFileNamePattern('[randomhash].[extension]')
->setRequired(false),
TextField::new('typedeplanche'),
TextField::new('marque'),
IntegerField::new('taille'),
IntegerField::new('epaisseur'),
MoneyField::new('prix')->setCurrency('EUR'),
IntegerField::new('litrage'),
TextField::new('etatusage'),
TextField::new('typedederive'),
TextareaField::new('description'),
TextField::new('niveau'),
TextField::new('vendeur'),
BooleanField::new('vendueavecderives'),
AssociationField::new('category')
];
}
}