Ckeditor 4.5 fileUploadRequest event does not fire

I have textarea with html id "id_textarea".

editor = CKEDITOR.inline( 'id_textarea', { filebrowserBrowseUrl : 'browse_url', filebrowserUploadUrl : 'upload_url' }); editor.on( 'fileUploadRequest', function( evt ) { console.log("This is not printing"); }); 

Whenever I try to download a file, it doesn't print anything for the console. Am I doing something wrong?

By the way, my requirement is to add csrf headers before sending a request for which I need to catch some kind of event like fileUploadRequest.

+3
source share
1 answer

I assume that you are trying to upload files through the Download tab in the Image Properties dialog box. It provides a plug-in for the file browser and fileButton , which does not support fileUploadRequest and fileUploadResponse (there is already a function request with a more detailed description of this case).

If you want to use these events to pre-process user requests, you can use the Upload Image plugin. The setup process is described in white papers, but keep in mind that it will only work to delete or insert files. Uploading through the Image Properties dialog box will still be handled by a file browser plugin that does not support these events.

The important thing is that with CKEditor 4.5.6, the File Browser plugin uses the CSRF header , so it can probably be used on your server side without any JavaScript code changes. Therefore, if you are using an older version, I suggest upgrading to 4.5.6 (using, for example, CKBuilder ) and try to integrate with your backend. The CSRF header in the file browser plugin should be sufficient for your needs.

Here is the title: enter image description here

+6
source

Source: https://habr.com/ru/post/914592/


All Articles