简体   繁体   English

上载图像抛出ckeditor

[英]Uploading image throw ckeditor

I'we html code for the editor: 我为编辑器添加了html代码:

<div id="editor">
    <h1>Hello world!</h1>
    <p>I'm an instance of <a href="http://ckeditor.com">CKEditor</a>.</p>
</div>

And javascript for it. 和JavaScript的。

if (CKEDITOR.env.ie && CKEDITOR.env.version < 9) {
    CKEDITOR.tools.enableHtml5Elements(document);
}
CKEDITOR.config.height = 150;
CKEDITOR.config.width = 'auto';
CKEDITOR.config.defaultLanguage = 'en';
CKEDITOR.config.language = 'en';
CKEDITOR.config.extraPlugins = 'uploadimage,filebrowser';
CKEDITOR.config.toolbarCanCollapse = true;
function loadEditor(id) {
    if (CKEDITOR.revision === ('%RE' + 'V%') || !!CKEDITOR.plugins.get('wysiwygarea')) {
        CKEDITOR.replace(id);
    } else {
        CKEDITOR.document.getById(id).setAttribute('contenteditable', 'true');
        CKEDITOR.inline(id);
    }
}
loadEditor('editor');

Can somebody give me a simple explanation how to make that i can upload image straight throw ckeditor. 有人可以给我一个简单的解释,如何使我可以直接上传图像ckeditor。 I've been trying over a week to do it. 我已经尝试了一个多星期。 I downloaded plugins uploadimage, and it's dependencies plugins. 我下载了插件uploadimage,它是依赖插件。 No "Upload" tag appear in "Image Properties" window. 在“图像属性”窗口中没有“上传”标签。 Thank you 谢谢

UploadImage add-on only works for dropped or pasted images. UploadImage附加组件仅适用于拖放的图像或粘贴的图像。 If you only want Upload tab in Image Properties, you have to set config.filebrowserImageUploadUrl to a script that will handle the upload: 如果只需要“图像属性”中的“上载”选项卡,则必须将config.filebrowserImageUploadUrl设置为将处理上载的脚本:

config.filebrowserImageUploadUrl = '/uploader/upload.php?type=Images';

Your upload.php should be like this (taken from Integrating CKEditor with a Custom File Browser , example 3): 您的upload.php应该是这样的(摘自CKEditor与Custom File Browser的集成 ,示例3):

<?php
// Required: anonymous function reference number as explained above.
$funcNum = $_GET['CKEditorFuncNum'] ;
// Optional: instance name (might be used to load a specific configuration file or anything else).
$CKEditor = $_GET['CKEditor'] ;
// Optional: might be used to provide localized messages.
$langCode = $_GET['langCode'] ;

// Check the $_FILES array and save the file. Assign the correct path to a variable ($url).
$url = '/path/to/uploaded/file.ext';
// Usually you will only assign something here if the file could not be uploaded.
$message = '';

echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM