0

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

damian
  • 49
  • 5
  • have you set the right permission on your server for the "uploads" folder? – gp_sflover Aug 11 '22 at 13:14
  • hm nope. I have to use the chmod command for this directory ? or is it in the VirtualHost configuration ? (that's my first app, i don't get everything at the first time sorry ) – damian Aug 11 '22 at 17:16
  • As the error highlight, this could be a permission issue so you need to check if that folder have the right permission, and yes you can use a chmod command from your control panel to set it. – gp_sflover Aug 12 '22 at 10:37
  • It s good now . Effectively, this folder was not rewritable.. i use chmod to change the permission and it s working now . Thanks – damian Aug 14 '22 at 10:40

0 Answers0