FCKeditor2.6.7 for PHP配置及中文上传乱码解决

7 篇文章 0 订阅
2 篇文章 0 订阅

1、首先去官网下载FCKeditor2.6.7 (版本好像只有一种,应该是多国语言版的)。http://ckeditor.com/download

注意:第一个为最新3.0.1版,第二个才是FCKeditor 2.6.5

现在最新的FCKeditor是叫ckeditor了。   我们这里是要下载FCKeditor 2.6.7,注意下载的链接。 

http://sourceforge.net/project/downloading.php?group_id=75348&filename=FCKeditor_2.6.7.zip

2、删除不必要的东西:

删除/FCKeditor/目录下除fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplates.xml,fckeditor.php,fckeditor_php5.php,fckeditor_php4.php
七个文件以外的所有文件;
删除目录/editor/_source(基本上,所有_开头的文件夹或文件都是可选的);
删除/editor/filemanager/connectors/下除了php目录的所有目录;
删除/editor/lang/下的除了 en.js, zh.js, zh-cn.js三个文件的所有文件。

3、打开/FCKeditor/fckconfig.js
修改
var FCKConfig.DefaultLanguage = 'zh-cn' ;(这里我设置是en的,好像也可以)
var _FileBrowserLanguage   = 'php' ;
var _QuickUploadLanguage   = 'php' ;
要开启文件上传的话,还需要配置editor\filemanager\connectors\php\config.php
将$Config['Enabled'] = false ;改为$Config['Enabled'] = true ;
更改$Config['UserFilesPath'] = '/userfiles/' ;为你的上传目录;

4.调用方法(例子)
将FCKeditor放在网站根目录
在PHP文件里面,包含/FCKeditor/fckeditor.php文件
//包含fckeditor类
include("../FCKeditor/fckeditor.php") ;
//设置编辑器路径
$sBasePath = "/FCKeditor/";
//创建一个Fckeditor,表单的txtarea名称为content
$oFCKeditor = new FCKeditor('content') ;
$oFCKeditor->BasePath   = $sBasePath ;
//设置表单初始值
$oFCKeditor->Value   = 'This is some <strong>sample text</strong>' ;
$oFCKeditor->Create() ;

//还可设置
$oFCKeditor->Width
$oFCKeditor->Height
$oFCKeditor->ToolbarSet
......................................................................................................................................................
<textarea name="content" style="display:none">这是文章内容测试!</textarea>
<?php
include_once("fckeditor/fckeditor.php");

$oFCKeditor=new fckeditor('content');
$oFCKeditor->BasePath='fckeditor/';
$oFCKeditor->value='default text in editor';
$oFCKeditor->Width='800px';
$oFCKeditor->Height='300px';
$oFCKeditor->create();
//$fck=$oFCKeditor->CreateHtml();
?>
......................................................................................................................................................

对于Fckeditor上传中文名文件时显示乱码的问题,方法如下:
测试环境:php 5 , utf-8编码

1、修正上传中文文件时文件名乱码问题
在文件connectors/php/commands.php中查找:
$sFileName = $oFile['name'] ;
在后面添加一行:
$sFileName = iconv("utf-8","gbk",$sFileName);

2、修正文件列表时中文文件名显示乱码问题
在文件connectors/php/util.php中查找:
return ( utf8_encode( htmlspecialchars( $value ) ) ) ;
修改为:
return iconv('gbk','utf-8',htmlspecialchars( $value ));

3、修正新建中文文件夹时的文件夹名乱码问题
在文件connectors/php/commands.php中查找:
$sNewFolderName =
在后面添加一行:
$sNewFolderName = iconv("utf-8","gbk",$sNewFolderName);

2.6.3版及后续版本的fck下的html文件已经加了utf-8的文件头。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

概念西瓜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值