SyliusCmsPlugin icon indicating copy to clipboard operation
SyliusCmsPlugin copied to clipboard

Uploading files (not images) gives a 400 popup error

Open olia-bn opened this issue 6 years ago • 3 comments

I am bale to upload images, but uploading a PDF gives an error: HTTP error occurred during file upload (error status: 400).

This is easy to test because same issue happens on the demo site.

olia-bn avatar Jan 06 '20 11:01 olia-bn

Hi @olia-bn

Currently only images are allowed, as you can see valides Mime types are 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'. at src/Controller/Action/Admin/UploadEditorImageAction.php#L67

Do you want to create a PR to add the ability of uploading PDFs ?

oallain avatar Jan 06 '20 12:01 oallain

I see. This action makes sense when inserting an image, but uploading files is also enabled when inserting a link.

So how I see it, it is WAI when accessed via "Insert image" but a bug when accessed via "Insert link". This would probably call for a separate action when inserting a link, how would you get around doing that?

olia-bn avatar Jan 07 '20 09:01 olia-bn

Extend WysiwygType.php and split actions for upload image and upload file https://github.com/BitBagCommerce/SyliusCmsPlugin/blob/a9e908c97e02010ccfb87b047d2a6495a704e478/src/Form/Type/WysiwygType.php#L35

'filebrowserUploadUrl' => $this->urlGenerator->generate('app.cms.admin.upload_editor_file'), 'filebrowserImageUploadUrl' => $this->urlGenerator->generate('bitbag_sylius_cms_plugin_admin_upload_editor_image'),

keeper7 avatar Jan 12 '20 13:01 keeper7

Hello @olia-bn, Closing because it's an old issue, by default we only allow adding photos.

liszkapawel avatar Mar 24 '23 13:03 liszkapawel