Upload Image on EasyAdmin V3

I can’t upload an image from EasyAdmin V3, I also added VichUpload. I must write setUploadDir() otherwise I have this error message : enter image description here

and if I put this method I have this message: enter image description here

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 AppControllerAdmin;

use AppEntityPlanches;
use EasyCorpBundleEasyAdminBundleControllerAbstractCrudController;
use EasyCorpBundleEasyAdminBundleFieldAssociationField;
use EasyCorpBundleEasyAdminBundleFieldBooleanField;
use EasyCorpBundleEasyAdminBundleFieldImageField as ImageFields;
use EasyCorpBundleEasyAdminBundleFieldIntegerField;
use EasyCorpBundleEasyAdminBundleFieldMoneyField;
use EasyCorpBundleEasyAdminBundleFieldSlugField;
use EasyCorpBundleEasyAdminBundleFieldTextareaField;
use EasyCorpBundleEasyAdminBundleFieldTextField;
use EasyCorpBundleEasyAdminBundleFieldImageField;
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')
        ];

        }
    
    }

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *