ov-i / ovcommerce

Projekt E-commerce bazujący na Symfony. Projekt aby się czegoś nowego nauczyć
0 stars 0 forks source link

Błąd podczas próby dodania produktu #11

Closed PanKunik closed 1 year ago

PanKunik commented 1 year ago

Po zalogowaniu się na konto administratora przy próbie dodania nowego produktu pojawia się błąd:

obraz

Stack trace:

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

  at vendor/symfony/form/ResolvedFormType.php:78
  at Symfony\Component\Form\ResolvedFormType->createBuilder(object(FormFactory), 'cover_url', array('required' => true, 'row_attr' => array('class' => 'field-image'), 'attr' => array('data-ea-align' => 'center'), 'label' => 'Cover Url', 'upload_filename' => '[uuid]_[slug].[extension]', 'upload_dir' => '/var/www/public/uploads/products/'))
     (vendor/symfony/form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php:61)
  at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->createBuilder(object(FormFactory), 'cover_url', array('required' => true, 'row_attr' => array('class' => 'field-image'), 'attr' => array('data-ea-align' => 'center'), 'label' => 'Cover Url', 'upload_filename' => '[uuid]_[slug].[extension]', 'upload_dir' => '/var/www/public/uploads/products/'))
     (vendor/symfony/form/FormFactory.php:54)
  at Symfony\Component\Form\FormFactory->createNamedBuilder('cover_url', object(ResolvedTypeDataCollectorProxy), null, array('required' => true, 'row_attr' => array('class' => 'field-image'), 'attr' => array('data-ea-align' => 'center'), 'label' => 'Cover Url', 'upload_filename' => '[uuid]_[slug].[extension]', 'upload_dir' => '/var/www/public/uploads/products/'))
     (vendor/easycorp/easyadmin-bundle/src/Form/Type/CrudFormType.php:105)
  at EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType->buildForm(object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'error_mapping' => array(), 'allow_extra_fields' => true, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'block_prefix' => null, 'row_attr' => array(), 'label_html' => false, 'attr' => array('class' => 'ea-new-form', 'id' => 'new-Product-form'), 'translation_domain' => 'messages', 'priority' => 0, 'form_attr' => false, 'data' => object(Product), 'data_class' => 'App\\Entity\\Product', 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'action' => '', 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'is_empty_callback' => null, 'getter' => null, 'setter' => null, 'validation_groups' => null, 'constraints' => array(), 'entityDto' => object(EntityDto)))
     (vendor/symfony/form/ResolvedFormType.php:99)
  at Symfony\Component\Form\ResolvedFormType->buildForm(object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'error_mapping' => array(), 'allow_extra_fields' => true, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'block_prefix' => null, 'row_attr' => array(), 'label_html' => false, 'attr' => array('class' => 'ea-new-form', 'id' => 'new-Product-form'), 'translation_domain' => 'messages', 'priority' => 0, 'form_attr' => false, 'data' => object(Product), 'data_class' => 'App\\Entity\\Product', 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'action' => '', 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'is_empty_callback' => null, 'getter' => null, 'setter' => null, 'validation_groups' => null, 'constraints' => array(), 'entityDto' => object(EntityDto)))
     (vendor/symfony/form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php:76)
  at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->buildForm(object(FormBuilder), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'auto_initialize' => true, 'trim' => true, 'required' => true, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'compound' => true, 'method' => 'POST', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'error_mapping' => array(), 'allow_extra_fields' => true, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'block_prefix' => null, 'row_attr' => array(), 'label_html' => false, 'attr' => array('class' => 'ea-new-form', 'id' => 'new-Product-form'), 'translation_domain' => 'messages', 'priority' => 0, 'form_attr' => false, 'data' => object(Product), 'data_class' => 'App\\Entity\\Product', 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'action' => '', 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'is_empty_callback' => null, 'getter' => null, 'setter' => null, 'validation_groups' => null, 'constraints' => array(), 'entityDto' => object(EntityDto)))
     (vendor/symfony/form/FormFactory.php:58)
  at Symfony\Component\Form\FormFactory->createNamedBuilder('Product', object(ResolvedTypeDataCollectorProxy), object(Product), array('attr' => array('class' => 'ea-new-form', 'id' => 'new-Product-form'), 'entityDto' => object(EntityDto), 'translation_domain' => 'messages', 'data' => object(Product)))
     (vendor/easycorp/easyadmin-bundle/src/Factory/FormFactory.php:53)
  at EasyCorp\Bundle\EasyAdminBundle\Factory\FormFactory->createNewFormBuilder(object(EntityDto), object(KeyValueStore), object(AdminContext))
     (vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:540)
  at EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController->createNewFormBuilder(object(EntityDto), object(KeyValueStore), object(AdminContext))
     (vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:535)
  at EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController->createNewForm(object(EntityDto), object(KeyValueStore), object(AdminContext))
     (vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:303)
  at EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController->new(object(AdminContext))
     (vendor/symfony/http-kernel/HttpKernel.php:163)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:74)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:184)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/var/www/vendor/autoload_runtime.php')
     (public/index.php:5)      
ov-i commented 1 year ago

A tak. Aktualnie to działa tak, że trzeba ręcznie utworzyć ten folder. Musze znaleźć sposób żeby symfony utworzyć to za mnie od razu, po ogarnięciu się serwera

cd public && mkdir -p uploads/products && chmod -R 644 uploads/

Niestety to nie rozwiąże problemu przy świeżym starcie projektu.

PanKunik commented 1 year ago

Dzięki! Zadziałało 😃👍🏻