ckeditor 4.5 fileUploadRequest event not firing

久未见 提交于 2019-12-07 13:49:23

问题


I have a 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 upload a file, it doesn't print anything to 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 event like fileUploadRequest.


回答1:


I assume that you are trying to upload files via the Upload tab in the Image Properties dialog. It is provided by the File Browser plugin and fileButton which does not support the fileUploadRequest and fileUploadResponse events (there is already a feature request with a more in-depth description of this case).

If you would like to use these events for some custom request preprocessing, you can use the Upload Image plugin. The configuration process is described in the official docs, but keep in mind that it will work only for dropping or pasting files. Upload via the Image Properties dialog will still be handled by the File Browser plugin which does not support these events.

The important thing here is that since CKEditor 4.5.6, the File Browser plugin uses the CSRF header so it can be probably used on your server side without any modifications in the JavaScript code. So if you are using an older version I suggest updating to 4.5.6 (using e.g. CKBuilder) and trying to integrate with your backend. The CSRF header in the File Browser plugin should be sufficient for your needs.

Here is the header:



来源:https://stackoverflow.com/questions/34851158/ckeditor-4-5-fileuploadrequest-event-not-firing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!