当前位置: 首页 > 知识库问答 >
问题:

CKEditor CKFinder图像上传

滑弘扬
2023-03-14

我正在使用CKEditor 4.5。2和CKFinder 3.0。PHP5.6上的0。一般来说,集成工作正常-当我单击CKEditor图像按钮时,我可以单击“浏览服务器”按钮,CKFinder打开,我可以选择图像,也可以进行上传。

不起作用的是image2对话框中的“上载”选项卡。我总是收到一个错误,说“请求的资源类型无效。”当我点击“发送到服务器”按钮时。

在我的CKFinder配置中,我定义了两种资源类型,称为Images;除了是只读的之外,它们本质上是相同的-我只想允许上传到Images类型...

有多种方式可以配置CKEditor和CKFinder之间的集成。我正在为CKEditor使用一个自定义JS配置文件,并使用setupCKEditor方法将ckFinder连接到它,如文档所示:

CKFinder.setupCKEditor(ckeditor_1, {
    'height': '100%',
    'jquery': '/js/jquery-1.11.3.min.js',
    'skin': 'jquery-mobile',
    'swatch': 'a',
    'themeCSS': '/themes/mytheme.min.css',
    'filebrowserBrowseUrl': '/ckfinder/ckfinder.html',
    'filebrowserImageBrowseUrl': '/ckfinder/ckfinder.html?Type=Images',
    'filebrowserImageUploadUrl':  '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'
}, "Images");

我尝试过在我的CKEDITOR.替换调用中向CKEditor传递相同的值,并在我的外部配置文件中的config属性上设置它们,但是没有任何变化-我仍然得到相同的错误。

我该怎么做呢?或者,由于CKFinder上传器工作正常,我如何禁用图像2对话框中的上传选项卡?

更新:以下是我当前创建CKEditor和CKFinder实例的代码:

var ckeditor_1 = CKEDITOR.replace('html', {
    "baseHref":"http://mysite.mac.local/",
    "toolbarStartupExpanded":true,
    "extraPlugins":"symbol",
    "customConfig":"/js/ckconfig.js"
});
CKFinder.setupCKEditor( ckeditor_1, {
    'height': '100%',
    'jquery': '/js/jquery-1.11.3.min.js',
    'skin': 'jquery-mobile',
    'swatch': 'a',
    'themeCSS': '/themes/mytheme.min.css'
}, { type: "Images" } );

和我的CKEditor配置文件:

CKEDITOR.editorConfig = function (config) {

    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
    config.toolbarGroups = [
        {name: 'document', groups: ['mode', 'document', 'doctools']},
        {name: 'clipboard', groups: ['clipboard', 'undo']},
        {name: 'editing', groups: ['find', 'selection', 'spellchecker']},
        {name: 'links'},
        {name: 'insert'},
        {name: 'tools'},
        {name: 'others'},
        '/',
        {name: 'basicstyles', groups: ['basicstyles', 'cleanup']},
        {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']},
        {name: 'styles'},
        {name: 'colors'},
        {name: 'about'},
        {name: 'symbol'}
    ];
    config.removePlugins = 'templates,save,specialchar,image,flash,scayt,forms,wsc,print,iframe,pagebreak';
    CKEDITOR.plugins.addExternal('symbol', '/ckeditorplugins/symbol/', 'plugin.js');
    config.extraPlugins = 'symbol';
    config.templates_replaceContent = false;
    config.templates_files = [
        '/ckeditorplugins/templates/templates.js'
    ];
    config.allowedContent = true;
    config.toolbarCanCollapse = true;
    config.fullPage = true;
    config.skin = 'bootstrapck';
    config.height = 400;
    config.uiColor = '#f9dda0';
    config.autoParagraph = false;
    config.enterMode = CKEDITOR.ENTER_BR;
    CKEDITOR.on('instanceReady', function (ev) {
        ev.editor.dataProcessor.writer.selfClosingEnd = '>';
    });
};

共有1个答案

邢飞白
2023-03-14

看起来你混合了CKEditor和CKFinder的选项。CKFinder.setupCKEditor()的第二个参数是CKFinder配置,而您使用的所有文件浏览器*选项都属于CKEditor配置。请看看CKFinder.setupCKEditor()文档。第三个参数允许您定义上传URL参数,因此在这里您可以将上传指向Images

请尝试以下代码片段:

CKFinder.setupCKEditor(ckeditor_1, {
    'height': '100%',
    'jquery': '/js/jquery-1.11.3.min.js',
    'skin': 'jquery-mobile',
    'swatch': 'a',
    'themeCSS': '/themes/mytheme.min.css'
}, {type: "Images"});

使用CKFinder时。setupCKEditor()将自动设置CKEditor的上载路径,因此不需要显式配置它。

如果上述内容不适用于您,请同时提供创建ckeditor\u 1的代码。

 类似资料:
  • 一旦用户点击掩码映像,我们就允许用户上传自定义映像,如果只有一个掩码映像:https://codepen.io/kidsdial/pen/jjbvon就可以正常工作 要求: 但是如果有多个掩码映像,那么用户也应该能够上传所有掩码映像上的自定义映像[类似https://codepen.io/kidsdial/pen/rrmypr],但是现在它只适用于单个映像.... 2图像代码页:https://c

  • 一旦用户点击掩码映像,我们就允许用户上传自定义映像,如果只有一个掩码映像:https://codepen.io/kidsdial/pen/jjbvon就可以正常工作 要求: 但是如果有多个掩码映像,那么用户也应该能够上传所有掩码映像上的自定义映像[类似https://codepen.io/kidsdial/pen/rrmypr],但是现在它只适用于单个映像.... 2图像代码页:https://c

  • 我有以下代码: 美元这个- 没有出现警告/错误,提交成功,但我上传的图像不会显示在文件夹中/uploads/user/“我不知道为什么,我不知道如何检查我的上传路径是否正确。我希望有一些方向。但我确实用相同的代码从不同的函数上传了它的工作和图像显示。 我目前使用localhost。 表格如下:

  • 我正在尝试将一组照片上载到服务器,但请求失败。文件数组到达时总是显示为空。 req.body按预期显示数组。 图像通过Dropzone组件添加。(我尝试将其切换为标准输入,但它们似乎都以相同的方式传递文件) 图像被应用到FormData,名称图像文件在通过设置了多部分/表单数据标题的Axios POST请求发送之前被追加。 一旦传递到服务器,只有req.body似乎包含任何数据,req.files

  • 问题内容: 我希望能够在上传文件之前预览文件(图像)。预览操作应在浏览器中全部执行,而无需使用Ajax上载图像。 我怎样才能做到这一点? 问题答案: 请看下面的示例代码:

  • 我的makeWhiteTransparent方法如下所示: 我尝试将graphics.drawImage(newImage,null,0,0)更改为graphics.drawImage(newImage,0,0,null),并按照建议将TYPE_4BYTE_ABGR更改为TYPE_INT_ARGB,但没有任何效果。错误仍然存在。