ckeditor 4.5 fileUploadRequest事件未触发 [英] ckeditor 4.5 fileUploadRequest event not firing

查看:490
本文介绍了ckeditor 4.5 fileUploadRequest事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html ID为 id_textarea的文本区域。

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?

顺便说一句,我的要求是在发送请求之前添加csrf标头,而我需要捕获该事件,例如fileUploadRequest。

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

推荐答案

我假设您正在尝试通过图像属性对话框中的上载选项卡上载文件。它由文件浏览器插件 fileButton ,它不支持< a href = http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-fileUploadRequest rel = nofollow noreferrer> fileUploadRequest fileUploadResponse 事件(已经有一个功能请求,并且

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.

重要的是由于 CKEditor 4.5.6 ,文件浏览器插件使用 CSRF标头,因此无需修改即可在服务器端使用它在JavaScript代码中。因此,如果您使用的是旧版本,建议升级到4.5.6(例如,使用 CKBuilder )并尝试集成与您的后端。文件浏览器插件中的CSRF标头应足以满足您的需求。

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.

此处是标头:

这篇关于ckeditor 4.5 fileUploadRequest事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆