PHP插件 FCKeditor 编辑器

本文介绍如何在项目中集成FCKeditor编辑器插件,包括配置步骤、实例化对象及实现上传功能的方法。

<p>

思路,作为一个编辑器插件 FCKeidtor可以说功能非常全面,下面简单说下如何在自己的开发项目中使用这个插件

首先,下载到FCKeidtor这个软件包 点击下载

然后解压缩复制到项目根目录 并改名为比较简单的名字 editor

首先打开fckeidtor.php 发现作用是判断服务器的PHP版本,4.0就引入4.0的类,5.0就引入5.0的类

 
 
  1. if !function_exists('version_compare'|| version_compare( phpversion(), '5''<' 
  2.     include_once'fckeditor_php4.php' 
  3. else 
  4.     include_once'fckeditor_php5.php' 

然后新建一个PHP页面 new_add.php 内容如下

 
 
  1. <?  
  2.  
  3. include ("editor/fckeditor.php");  
  4. $oBasePath $_SERVER['PHP_SELF'];//用$_SERVER函数得到当前文件的实际路径,这里包括文件名  
  5.  
  6. $oBasePath dirname ($oBasePath)."/editor/";  
  7. $ed new FCKeditor("con"); //实例化FCKeditor对象 给name为con  
  8. $ed->BasePath $oBasePath//程序的地址为上面得到的路径  
  9. //$ed->ToolbarSet "Basic"; 是否使用简单模式的开关  
  10. ?>  
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  12. <html xmlns="http://www.w3.org/1999/xhtml">  
  13. <head>  
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  15. <title>无标题文档</title>  
  16. </head>  
  17.  
  18. <body>  
  19. <?  
  20.  
  21. if($_POST[sub])//判断$_POST[sub]是否为真,真为有内容提交  
  22.    
  23. {  
  24.     $con $_POST[con];//读取FCKeditor中的内容  
  25.     $con str_replace('\\','',$con); //替换\为空,为了让网址能正常显示  
  26.     echo "文章标题:".$_POST[title].  
  27.      "<br>文章内容".$con//输出接收的内容  
  28. }  
  29.  
  30. ?>  
  31. <form method="post" action="">  
  32. 文章标题<input type="text" name="title" />  
  33. <? $ed->Create(); //创建一个FCKeditor的窗口?>   
  34. <input type="submit" name="sub" value="提交新闻" />  
  35. </form>  
  36. </body>  
  37. </html>  
  38.  

最重要的步骤是 

  1. $oBasePath $_SERVER['PHP_SELF'];//用$_SERVER函数得到当前文件的实际路径,这里包括文件名  
  2.  
  3. $oBasePath dirname ($oBasePath)."/editor/";  
  4. $ed new FCKeditor("con"); //实例化FCKeditor对象 给name为con  
  5. $ed->BasePath $oBasePath//程序的地址为上面得到的路径  

如果要FCKeditor可以上传图片的话,要开启editor\editor\filemanager\connectors\php\config.php里面

找到 $Config['Enabled'] =  false; 这是默认的

修改为 $Config['Enabled'] = true ;

找到$Config['UserFilesPath'] = '/userfiles/' ; 这是上传文件的路径改为自己的路径

如 $Config['UserFilesPath'] = '/class/userfiles/' ; 就是我的localhost/class/路径下的userfiles文件夹

</p>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值