I've made an application for my exams using symfony 6, Easyadmin4 and debian10 for my dedicated server.
I create in EasyAdmin, an Header feature to change my header from my EasyAdmin menu.
There is the code for my ProductCrudController.
<?php
namespace App\Controller\Admin;
use App\Entity\Product;
use EasyCorp\Bundle\EasyAdminBundle\Field\SlugField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
class ProductCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Product::class;
}
public function configureFields(string $pageName): iterable
{
return [
TextField::new('name'),
SlugField::new('slug')
->setTargetFieldName('name'),
ImageField::new('illustration')
->setBasePath('uploads')
->setUploadDir('public/uploads')
->setUploadedFileNamePattern('[randomhash].[extension]')
->setRequired(false),
TextField::new('subtitle'),
TextareaField::new('description'),
BooleanField::new('isBest'),
MoneyField::new('price')
->setCurrency('EUR'),
AssociationField::new('category')
];
/* return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
]; */
}
}
I store my uploads in myappanme/public/uploads
Everything works fine using my local server Mamp, but online it's not working.
I have this error :
An error has occurred resolving the options of the form
"EasyCorp\Bundle\EasyAdminBundle\Form\Type\FileUploadType": Invalid upload directory
"/var/www/sodelicious/public/uploads/" it does not exist or is not writable.
My uploads folder /var/www/sodelicious/public/uploads
is there. I don't understand why i have this symfony error.
I've tried to change the syntax of my ->setUploadDir
but the error persists.
If anybody can tell me what i am doing wrong it would be nice, thanks