close

這次因為case的關系有用到編輯器CKeditor
http://ckeditor.com/

但因為有用到圖片上傳功能,因此再加入CKfinder
http://ckfinder.com/

由於在2.x上,這兩個功能是做在一起的,因應安全性在3.x版已分開

因此在設定上已有所不同
在CKeditorg的config.js上所需要設定的有




#版面,有kama,v2,office2003三種版型
config.skin = 'kama';
#版本語言,預設是中文
//config.language = 'zh-cn';
#功能全開
config.toolbar = 'Full';

config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; //可上傳一般檔案
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';//可上傳圖檔
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';//可上傳Flash檔案
#寬度
//config.width = 1000;
#高度
//config.height = 600;
config.entities = true;



設定完畢之後,接著在需要放上CKeditor的地方PHP碼為





#用於html的textraea欄位設定 textarea name="content" id="content"


#php寫法=================
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("content");

$CKEditor = new CKEditor();
$CKEditor->returnOutput = true;
$CKEditor->basePath = '/ckeditor/';

CKFinder::SetupCKEditor($CKEditor, '/ckfinder/') ;//注意这里是相对路径,相对于根目录,不能用绝对路径

$contentarea = $CKEditor->editor("content", $rs['contents']);




這樣就放上CKeditor的功能了,若要再加上圖片上傳的功能,則要再CKfinder的config.php中設定




function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...

// return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
// user logs in your system. To be able to use session variables don't
// forget to add session_start() at the top of this file.

return true;
//預設為false
}

#由於這邊是打絕對路徑,就看到時後圖片是放在那裡了
$baseUrl = 'http://'.$_SERVER['SERVER_NAME'].'/mail/upload/';


並將預定要放圖片的資料夾設定為777開啟權限,完成!


出現錯誤訊息: It Was Not Possible To Complete The Request Due To File System Permission Restrictions.


後來將資料夾權限設定為777,以及將CKfinder的config.php中的$baseUrl 參數設定為絕對路徑,解決。

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 許敦凱 的頭像
    許敦凱

    許敦凱的部落格

    許敦凱 發表在 痞客邦 留言(0) 人氣()