2

I have been seeking for any thread with the related issue, but couldn't find one, I'm trying to set an image upload for ckeditor5-react, picking up a file via file browser works fine but I get an alert "cannot upload file"

Here is my code below:

<CKEditor
    editor={ ClassicEditor } 
    onChange={ ( event, editor ) => console.log( { event, editor } ) }
    config={{
         ckfinder:{uploadUrl: "/uplaodImageFromEditor"}
      }}
    UploadAdapter={FileRepository}
 />
Maciej Bukowski
  • 3,240
  • 23
  • 28
Sonke
  • 35
  • 1
  • 2
  • 9

1 Answers1

4

First of all, there's no UploadAdapter property available in the CKEditor component.

Secondly, the image feature is based on the image upload, so you need to configure your backend, so the uploaded images can be stored somewhere. As it's explained in the How to enable image upload support in CKEditor 5?, so you have a few options.

If you want to use the CKFinder, then you need to install the CKFinder and provide a correct URL in the ckfinder.uploadUrl config. Eventually, you can use this URL as the endpoint for your own backend - see how the backend responses should look like for the ckfinder.uploadUrl config.

Maciej Bukowski
  • 3,240
  • 23
  • 28
  • 1
    Thanks a lot, I have finally configured everything correctly. – Sonke Sep 26 '18 at 08:34
  • What is meant by the `FileRepository` attached on the `UploadAdapter` ? – Lutaaya Huzaifah Idris Oct 22 '18 at 14:29
  • [FileRepository](https://ckeditor.com/docs/ckeditor5/latest/api/module_upload_filerepository-FileRepository.html) is a plugin that you can reach via `editor.plugins.get( 'FileRepository' )`. The uploader can be set on this plugin using the `createUploadAdapter` method. – Maciej Bukowski Oct 22 '18 at 14:35
  • @sonke how did you configure it in the end? – David Nelband Mar 20 '19 at 13:27
  • @Sonke I am still getting alert cannot upload file even though I get success from the backend and I see my image uploaded. How to remove this alert? – user254153 Nov 17 '19 at 03:36
  • Hi @DavidNelband , I'm sorry for taking so long, I can't remember how I resolved that issue but I will check and give a feedback. – Sonke Dec 05 '19 at 08:38