簡體   English   中英

上載圖像拋出ckeditor

[英]Uploading image throw ckeditor

我為編輯器添加了html代碼:

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

和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');

有人可以給我一個簡單的解釋,如何使我可以直接上傳圖像ckeditor。 我已經嘗試了一個多星期。 我下載了插件uploadimage,它是依賴插件。 在“圖像屬性”窗口中沒有“上傳”標簽。 謝謝

UploadImage附加組件僅適用於拖放的圖像或粘貼的圖像。 如果只需要“圖像屬性”中的“上載”選項卡,則必須將config.filebrowserImageUploadUrl設置為將處理上載的腳本:

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

您的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