CKEditor中没有触发UploadFile回调 [英] UploadFile callback is not being triggered in CKEditor

查看:467
本文介绍了CKEditor中没有触发UploadFile回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新的Full CKEditor( 4.5.3 )启用Office2013样式。

I am using latest Full CKEditor (4.5.3) with Office2013 style enabled.

我在这里添加了filebrowserImageUploadUrl选项:

I added filebrowserImageUploadUrl option here:

CKEDITOR.replace( 'news_content' ,
            {
                "filebrowserImageUploadUrl": "/path/to/script.php"
            });

当上传图片时,支持将正确的HTML和头文件返回给CKEditor,只是显示JavaScript代码,并没有实际触发。如果我将JS复制粘贴到浏览器(Chrome)控制台 - 它的工作原理(切换标签到第一个并输入图像)。

When an image is uploaded, backed is returning proper HTML and headers to CKEditor, but what it does - just displays that JavaScript code and doesn't actually trigger that. If I copy-paste that JS to the browser (Chrome) console - it works (switches tab to the first one and inputs the image).

请附上萤幕撷取画面。我错过了什么?

Please find screenshot attached. What have I missed?

PS>第一个参数是从文件被上传时的请求,所以在这种情况下它= 1(这不是问题:))

P.S> The first argument is taken from the Request when file is being uploaded, so in that case it's = 1 (it's not the issue :))

推荐答案

由于@Wiktor猜到的问题是设置正确的标题。

As it was guessed by @Wiktor the issue was in setting proper headers. I was almost there, setting wrong headers.

右边标题显然是text / html(不是plain / text在这种情况下,它只是一个文本)

Right headers are obviously: "text/html" (not "plain/text", it recognizes it just as a text in this case)

    $uploadResponse = new Response();
    $uploadResponse->headers->set('Content-type', 'text/html');

    $content = "<script type=\"text/javascript\">\n";
    $content .= "window.parent.CKEDITOR.tools.callFunction(" . $funcNum . ", '/uploads/news_image/" . $response['uploadedName'] . "', '');\n";
    $content .= "</script>";

    $uploadResponse->setContent($content);

这篇关于CKEditor中没有触发UploadFile回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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