EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.09k stars 1.03k forks source link

ImageField #4123

Open HaisRodolphe opened 3 years ago

HaisRodolphe commented 3 years ago

Describe the bug An error occurred while resolving the options of the form "EasyCorp \ Bundle \ EasyAdminBundle \ Form \ Type \ FileUploadType": Invalid upload directory "C: \ laragon \ www \ e-commerce symfony \ laboutiquefrancaise \ laboutiquefrancaise / public / uploads \ "it does not exist or is not writable.

Software laragon. coding: ImageField::new('illustration') ->setBasePath('uploads/') ->setUploadDir('public/uploads') ->setUploadedFileNamePattern('[randomhash].[extension]') ->setRequired(false), thank you so much Icône de validation par la communauté Validée

ghost commented 3 years ago

Hello, i have the same problems.

Open the file :

EasyCorp\Bundle\EasyAdminBundle\ Form\Type\ FileUploadType.php

Go to line 161 to 163 and comment it.

/* if (0 !== mb_strpos($value, \DIRECTORY_SEPARATOR)) {
               $value = $this->projectDir.'/'.$value;
            }
 */

It's work.

HaisRodolphe commented 3 years ago

Hello, Yes, I have commented on line 161 to 163. But the problem persists. Thank you in advance for your answers

alexandre-leng commented 3 years ago

Hello i have the same problem ant this error An error has occurred resolving the options of the form "EasyCorp\Bundle\EasyAdminBundle\Form\Type\FileUploadType": Invalid upload directory "C:\Users\alexa\Documents\AAA_projet\Projet\laboutiqueinformatique/C:\Users\alexa\Documents\AAA_projet\Projet\laboutiqueinformatique\public/uploads\" it does not exist or is not writable.

i need to comment line 161 to 163. of this file EasyCorp\Bundle\EasyAdminBundle\ Form\Type\ FileUploadType.php

BUT it didn't solve the problem fully.

ghost commented 3 years ago

Je pense que vous êtes des français, vue le nom "laboutiquefrancaise, laboutiqueinformatique" J'ai une autre solution pour vous afin d'éviter de commenter les lignes.

Allez-y dans votre CRUD CONTROLLER de produit :

ImageField::new('illustration') ->setBasePath('uploads') ->setUploadDir('public/uploads') // ICI QUE VOUS DEVEZ REMONTER VOS DOSSIERS ->setUploadedFileNamePattern('[randomhash].[extension]') ->setRequired(false),

Par exemple pour le cas de alexandre-leng :

An error has occurred resolving the options of the form "EasyCorp\Bundle\EasyAdminBundle\Form\Type\FileUploadType": Invalid upload directory "C:\Users\alexa\Documents\AAA_projet\Projet\laboutiqueinformatique/C:\Users\alexa\Documents\AAA_projet\Projet\laboutiqueinformatique\public/uploads\" it does not exist or is not writable.

Tu dois ici remonter jusqu'à ton dossier original qui est donc laboutiqueinformatique avant le "C:\Users.." Donc à partir de \public/ tu remonte, ça devrait te faire 7 dossier à remonter, essaye de tester. Du coup ça donne :

ImageField::new('illustration') ->setBasePath('uploads') ->setUploadDir('../../../../../../../public/uploads') ->setUploadedFileNamePattern('[randomhash].[extension]') ->setRequired(false),

HaisRodolphe commented 3 years ago

Thank you very much for your help, I just found it. It binds it to windows 10 and folder protection. I want to thank you for your help.

dam824 commented 2 years ago

hi, i have the same issue on my dedicated server.

An error has occurred resolving the options of the form "EasyCorp\Bundle\EasyAdminBundle\Form\Type\FileUploadType": Invalid upload directory "/var/www/myappname/public/uploads/" it does not exist or is not writable.

this is my script from ProductCrudControll :

ImageField::new('illustration') ->setBasePath('uploads') ->setUploadDir('public/uploads')

The problem is that my folder 'uploads' located in /var/www/myappname/public/upload/ exist, i don't understand why symfony can't go to this folder using this route.

If anybody can tell me what i am doing wrong, it would be nice.

Thank you