小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

php中ckeditor的配置方法

 顧于思文摘館 2012-12-19
ckeditor 編輯器php正確配置方法

1. 下載安裝 CKEditor:

http:///

解壓下載到的CKEditor放到網(wǎng)站的路徑中即可

2. 下載安裝 CKFinder:

http:///download

解壓下載到的CKFinder放到與CKEditor同一目錄中即可

3. 在網(wǎng)頁中使用 CKEditor 和 CKFinder:

CKEditor 實(shí)際是替換一個(gè) textarea 標(biāo)簽,所以把textarea放到一個(gè)form中,當(dāng)提交到php服務(wù)器端,使用$_GET['xxx'] 或者 $_POST['xxx'] 取得編輯好的數(shù)據(jù)。注意,因?yàn)?CKEditor 要替換 textarea,所以相應(yīng)的javascript 代碼"CKEDITOR.replace(xxxxxx)" 要放在 textarea 的后面。

最簡單的方法,直接新建一個(gè)test.html文件(和ckeditor、ckfinder處于同一級目錄)使用下面的例子修改一下即可。在瀏覽器里瀏覽test.html就可以在網(wǎng)頁中看到 CKEditor 了,興奮吧。

<html>

<head>

   <meta http-equiv="Content-type" content="text/html; charset=UTF-8">

   <title>CKEditor</title>
<script src="ckeditor/ckeditor.js"></script>

</head>

<body>

   <form action="b.php" method="post">

   <textarea name="editor1">CKEditor Demo</textarea>

   <input type="submit" name="submit" value="Submit" />

   </form>

</body>

 
<script type="text/javascript">

   // 啟用 CKEitor 的上傳功能,使用了 CKFinder 插件

   CKEDITOR.replace( 'editor1', {

   filebrowserBrowseUrl : 'ckfinder/ckfinder.html',

   filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?Type=Images',

   filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?Type=Flash',

   filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',

   filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',

   filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'

   });

</script>

</html>


4. 配置CKFinder進(jìn)行上傳圖片,F(xiàn)lash等。

到這里,點(diǎn)擊 "Image" 按鈕,在彈出的窗口中的 "Upload" 標(biāo)簽中已經(jīng)看到上傳按鈕了,但是在上傳文件時(shí)失敗。因?yàn)镃KFinder還沒有配置好。需要?jiǎng)?chuàng)建上傳文件的目錄和修改 ckfinder/config.php 里的三個(gè)地方:

a. 創(chuàng)建保存上傳文件的目錄,如upload

(把upload文件夾也放在和ckeditor、ckfinder處于同一級目錄,三個(gè)目錄都位于項(xiàng)目目錄下)

其路徑為 /upload/

[For Linux: 把其權(quán)限設(shè)置為php server可讀寫,最簡單的是 chmod 777 upload 這樣php server才有權(quán)限往里面保存文件.]


b. 找到配置文件(ckfinder/config.php)第32行,把 function CheckAuthentication() { return false; }

修改成 function CheckAuthentication() { return true; }

c. 找到第63行,把 $baseUrl 的值改成保存上傳文件存目錄的URL,

如 $baseUrl = '/項(xiàng)目名/upload/';(這里的地址要從項(xiàng)目目錄開始的絕對路徑,確定上傳目錄已經(jīng)存在)

d. 找到第82行,刪除 $baseDir = resolveUrl($baseUrl); 修改 $baseDir 為上傳文件目錄的絕對路徑,(不能刪除,否則不能上傳)(本地測試的時(shí)候要從磁盤的跟目錄下開始,即C:/或者D:/的直接目錄)

如$baseDir = '/Apache2/htdocs/ck/upload/'; (Apache2是D:/盤下的直接目錄)

這是因?yàn)閞esolveUrl($baseUrl)函數(shù)不能正常工作。

至此,可以使用 CKEditor 和 CKFinder 上傳文件了。

對上面這個(gè)小例子中服務(wù)器端的b.php代碼:

<?php

header("Content-Type:text/html; charset=utf-8");

$str = $_POST['editor1'];

echo $str;

?>

可以看到,在點(diǎn)擊submit按鈕后,服務(wù)器端收到了CKEditor中的內(nèi)容,并使用echo輸出,生成一個(gè)與CKEditor里面編輯的完全一樣的內(nèi)容。在服務(wù)器端可以把收到的內(nèi)容保存到數(shù)據(jù)庫中。然后再讀出在相應(yīng)的頁面顯示出來。

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多