[重要通告]如您遇疑難雜癥,本站支持知識付費(fèi)業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時(shí)間哦!

FCKeditor是一款非常優(yōu)秀的HTML在線編輯器,功能也可以定制. 也支持多種瀏覽器, 遵循LGPL版權(quán)。支持 asp、asp.net、html、php、pl、jsp 等等 使用最廣的一款在線HTML編輯器。

最新版本的FCKeditor(v2.6.6 正式版)同時(shí)兼容絕大多數(shù)主流瀏覽器,包括: IE 5.5及以上版本 (windows), 火狐Firefox 1.0及以上版本, 遨游Mozilla 1.3及以上版本,網(wǎng)景7.0及以上版本。

老版本不支持幾種字體大家可以在配置文件fckconfig.js里這一句這樣修改一下就可以了:

FCKConfig.FontNames= '宋體;黑體;隸書;楷體_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

在線編輯器FCKeditor在PHP中的使用方法:

FCKeditor是sourceforge.net上面的一個(gè)開源項(xiàng)目,主要是實(shí)現(xiàn)在線網(wǎng)頁編輯器的功能,官方網(wǎng)站為http://www.fckeditor.net ,在服務(wù)器端支持ASP.Net、ASP、ClodFusion、PHP、Java等語言,并且支持IE 5+、Mozilla 、Netscape等主流瀏覽器。目前最新版本為2.0 Beta 2,但是目前2.0 Beta版還不支持PHP,所以這里我選擇使用了1.6版本。

首先我們先到http://sourceforge.net/projects/fckeditor/ 下載FCKeditor_1.6.zip,并將其解壓縮到你的網(wǎng)站子目錄里面,并將文件夾名改為FCKeditor。進(jìn)入到FCKeditor/目錄下,打開_test/目錄,里面含有各種編程語言調(diào)用FCKeditor的方法,其中與PHP有關(guān)的文件有2個(gè)文件:
test.php //提交數(shù)據(jù)頁面
testsubmit.php //顯示數(shù)據(jù)頁面
大家可以看一下,了解FCKeditord的調(diào)用方法,下面是我簡寫了一個(gè)test程序:






" method="post" language="javascript">
BasePath = '../FCKeditor/' ;
// 將FCKeditor實(shí)例化
$oFCKeditor->CreateFCKeditor( 'EditorDefault', '100%', 300 ) ;
?>



從上面的例子中我們可以看到要使用FCKeditor,首先要執(zhí)行
include("../FCKeditor/fckeditor.php") ;語句來引用FCKeditor。然后執(zhí)行
$oFCKeditor = new FCKeditor ;
$oFCKeditor->BasePath = '../FCKeditor/' ;
$oFCKeditor->CreateFCKeditor( 'EditorDefault', '100%', 300 ) ;
來實(shí)例化FCKeditor,如果是編輯頁面則再加入一行:
//$Content可以是從數(shù)據(jù)庫中讀取出來的數(shù)據(jù)
$oFCKeditor->Value = $Content ;

默認(rèn)情況下,上傳圖片功能僅對應(yīng)于ASP方式,要想實(shí)現(xiàn)在PHP下上傳文件,還得對FCKeditor的配置文件進(jìn)行修改。打開/ FCKeditor/js/fck_config.js(這是FCKeditor的主配置文件),定位到文件的最下面那段被//注釋掉的內(nèi)容,將
//##
//## Image Browsing
//##
config.ImageBrowser = true ;
// Custom Page URL
config.ImageBrowserURL = config.BasePath + "filemanager/browse/sample_html/browse.html" ;
//config.ImageBrowserURL = config.BasePath + "filemanager/browse/sample_php/browse.php" ;
//config.ImageBrowserURL = config.BasePath + "filemanager/browse/sample_jsp/browse.jsp?type=img" ;
//config.ImageBrowserURL = config.BasePath + "filemanager/browse/sample_asp/browse.asp" ;

//##
//## Image Upload
//##
config.ImageUpload = true ;
// Page that effectivelly upload the image.
config.ImageUploadURL = config.BasePath + "filemanager/upload/asp/upload.asp" ;
//config.ImageUploadURL = config.BasePath + "filemanager/upload/aspx/upload.aspx" ;
//config.ImageUploadURL = config.BasePath + "filemanager/upload/cfm/upload.cfm" ;
//config.ImageUploadURL = config.BasePath + "filemanager/upload/php/upload.php" ;
//config.ImageUploadURL = config.BasePath + "filemanager/upload/jsp/upload.jsp" ;
改為
//##
//## Image Browsing
//##

config.ImageBrowser = true ;
// Custom Page URL config.
ImageBrowserURL = "filemanager/browse/sample_html/browse.html" ;
config.ImageBrowserURL = config.BasePath + "filemanager/browse/sample_php/browse.php" ;

//##
//## Image Upload
//##
config.ImageUpload = true ;
// Page that effectivelly upload the image.
config.ImageUploadURL = config.BasePath + "filemanager/upload/php/upload.php" ;

最后再修改2個(gè)文件:
/FCKeditor/filemanager/upload/php/upload.php
第22行
$UPLOAD_BASE_URL = '/userimages/';
/FCKeditor/filemanager/browse/sample_php/browse.php
第20行
$IMAGES_BASE_URL = '/FCKeditor/userimages/';
這兩處定義了圖片上傳到哪個(gè)目錄,可以自行定義,不過一定要確保該目錄存在,不然上傳圖片時(shí)會報(bào)錯(cuò)。
然后我們把FCKeditor目錄下的用不到的.asp、.jsp、. cfm文件和_test、_ aspnet、_developers、_docs、_jsp目錄都刪掉以節(jié)省空間。好啦,F(xiàn)CKeditor的基本使用方法就講到這里,大家感興趣的話可以到我的網(wǎng)站來看看效果:http://www.shaof.com 。

補(bǔ)充:
在FCKeditor官方的網(wǎng)站注明FCKeditor目前支持3種瀏覽器:IE5+,Mozilla and Netscape。但在實(shí)驗(yàn)中發(fā)現(xiàn)使用IE5.0是不支持圖片上傳功能,只有將IE升級到5.5或者6.0才能支持圖片上傳功能。而對于剛出的Mozilla Firefox 1.0 RC1以及Mozilla1.6(Linux環(huán)境),則完全無法使用FCKeditor。

FCKeditor編輯器配置

FCK老是提示“ Sorry, can\’t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php ”錯(cuò)誤,但是apache下正常但是IIS就有問題!

問題何在?

打開:editor/filemanager/connectors/php/config.php

找到:

配置文件

$Config['Enabled'] = true ;

$Config['UserFilesPath'] = ‘/userfiles/’ ;

$Config['UserFilesAbsolutePath'] = ” ;

修該$Config['UserFilesAbsolutePath'] = ‘絕對路徑\\userfiles\\’ ;

你可以修改成成自己的響應(yīng)路徑問題解決!

問題未解決?付費(fèi)解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信

所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!

支付寶贊助
微信贊助

免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。

您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對《免責(zé)聲明》全部內(nèi)容的認(rèn)可->聯(lián)系老梁投訴資源
LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。 敬請諒解! 侵權(quán)刪帖/違法舉報(bào)/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » FCKeditor編輯器在PHP中的使用方法

發(fā)表回復(fù)

本站承接,網(wǎng)站推廣(SEM,SEO);軟件安裝與調(diào)試;服務(wù)器或網(wǎng)絡(luò)推薦及配置;APP開發(fā)與維護(hù);網(wǎng)站開發(fā)修改及維護(hù); 各財(cái)務(wù)軟件安裝調(diào)試及注冊服務(wù)(金蝶,用友,管家婆,速達(dá),星宇等);同時(shí)也有客戶管理系統(tǒng),人力資源,超市POS,醫(yī)藥管理等;

立即查看 了解詳情