(使用步骤)ThinkPHP3.1.2中如何配置Ckeditor_4.1.1和Ckfindtor(转)

ThinkPHP3.1.2中如何配置Ckeditor_4.1.1和Ckfindtor  
一、下载Ckeditor和Ckfinder 
Ckeditor官网 http://ckeditor.com/download 
解压ckeditor,放入test2(项目)/Public/ckeditor. (删除里边的smaple文件夹) 
Ckfinder官网 http://cksource.com/ckfinder/download 解压Ckfinder,放入test2(项目)/Public/ckfinder. (删除里边的_smaple和help文件夹)  
基本目录结构  
 
 
二、在TPL/Index/index.html模板中引入ckeditor 

<!DOCTYPE html> 

<html> <head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ThinkPHP3.1.2中如何配置Ckeditor_4.1.1和Ckfindtor</title> 

<script type="text/javascript" src="__PUBLIC__/ckeditor/ckeditor.js"></script> </head> <body>  

<form action="__URL__/add" method="post"> <textarea name="content"></textarea> <input type="submit" value="提交" /> </form> 
<script type="text/javascript"> CKEDITOR.replace( 'content',{ 
filebrowserBrowseUrl : '__PUBLIC__/ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 
'__PUBLIC__/ckfinder/ckfinder.html?type=Images', filebrowserFlashBrowseUrl : 
'__PUBLIC__/ckfinder/ckfinder.html?type=Flash', filebrowserUploadUrl : 
'__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', 
filebrowserImageUploadUrl : 
'__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', 
filebrowserFlashUploadUrl : 
'__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash', }); 
</script> </body> </html>  
三、配置ckeditor 
打开ckeditor/config.js进行配置 
config.language = 'zh-cn'; //配置语言 

config.uiColor = '#AADC6E'; //界面颜色 config.width = 700; //宽度  config.height = 350; //高度 

这里是最基本的配置,其它配置可以从网上搜一下  


四、配置ckfinder,进行图片、falsh等上传功能 

1.在项目根目录下新建uploads文件夹

2.打开ckfinder/config.php文件 
把第33行中return false 改为 return true 
把第63行中$baseUrl 改为 $baseUrl = '/test2(项目)/uploads/';  

 

五、控制器IndexAction.class.php中的代码 
<?php 
// 本类由系统自动生成,仅供测试用途 class IndexAction extends Action {     public function index(){ $this->display();     } 
    public function add(){      dump($_POST);     } } 
运行效果: 
 
注意: 
上传中文文件时,会出现乱码,解决方法: 修改上传的文件名,打开
cdfinder/core/connector/php/php5/CommandHandler/FileUpload.php找到  

if ($sFileName != $sUnsafeFileName) { 
      $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED; } 
在后面加上下面这两句就可以解决中文乱码问题 
 $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);  $sFileName = date("Ymd")."_".date("His").".".$sExtension;(这两句话是放在花括号后)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值