2015-08-24 34 views
1

我正在使用插件image2,並希望能夠將圖像上傳到我們的服務器。獲取filebrowserUploadUrl以更新網址

我已經加入config.filebrowserUploadUrl =「/ CkeditorImageUpload」

到我config.js,和「圖像屬性」對話框確實有一個上載圖像標籤可將圖像上傳到我的服務器。到目前爲止這麼好,但問題是,當圖像上傳時,url字段不會在圖像屬性對話框中更新,因此用戶無法使用上傳的圖像。

我的/ CkeditorImageUpload應該返回一些特殊的東西來導致對話框更新?

回答

1

是的,CKEditor希望上傳腳本返回一個調用匿名函數的<script>標籤。

一切文檔http://docs.ckeditor.com/#!/guide/dev_file_browser_api中描述 - 參見實施例3用腳本的一個示例PHP發送文件上傳後的響應:

<?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>"; 
?> 
+0

工作正常。有一件事是:結果必須返回類型「文本/ HTML」 – MTilsted