EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

ImageField

Open HaisRodolphe opened this issue 4 years ago • 6 comments

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

HaisRodolphe avatar Jan 14 '21 21:01 HaisRodolphe

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.

bl4cksh4kur avatar Jan 15 '21 11:01 bl4cksh4kur

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

HaisRodolphe avatar Jan 16 '21 07:01 HaisRodolphe

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.

alexandre-leng avatar Jan 21 '21 09:01 alexandre-leng

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),

bl4cksh4kur avatar Jan 25 '21 00:01 bl4cksh4kur

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.

HaisRodolphe avatar Jan 25 '21 06:01 HaisRodolphe

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

dam824 avatar Aug 11 '22 12:08 dam824