zoukankan      html  css  js  c++  java
  • (使用步骤)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;(这两句话是放在花括号后)

     

  • 相关阅读:
    excel使用总结
    使用spring的@Scheduled注解执行定时任务,启动项目不输出警告
    web.xml配置错误导致applicationContext.xml配置重复加载
    POI3.8解决导出大数据量excel文件时内存溢出的问题
    linux常用命令总结
    javax.mail 发送邮件异常
    eclipse下创建maven项目
    java单例模式的几种写法比较
    msql数据迁移,myisam及innoDB
    JS监听回车事件
  • 原文地址:https://www.cnblogs.com/wuyinghong/p/3237378.html
Copyright © 2011-2022 走看看