主题: kindeditor 安装使用的错误修正,改进(上传修正的全攻略,jsp): (kindeditor
作者: newtower, 发布日期: 2012-11-03 11:22:55, 浏览数: 3846
2012-11-03 15:37:11

kde: kindeditor:

kindeditor 安装使用的错误修正,改进(上传修正的全攻略,jsp): (kindeditor-4.1.3), by 刘涛 qq: 30234923
改造后,可以在各种不同的jsp服务器运行,resin, tomcat 等

首先下载 kindeditor-4.1.3.zip 回来,【http://www.kindsoft.net/down.php】
假设你的网站发布目录为       [d:\xiaojinta.com\www\]
解压 kindeditor-4.1.3.zip 到 [d:\xiaojinta.com\www\kde\] 下, kde 下应有 kindeditor.js 等文件(examples目录等) 
手工创建上传目录,           [d:\xiaojinta.com\www\upload\], 否则会报【拒绝访问】【权限不足】类似的错误。
kindeditor 会在 upload 下自动继续建立 image, flash, media, file 等目录分类存放上传的文件
例如
www\upload\media\20121103\20121103111126_453.flv
www\upload\image\20121103\20121103091346_808.jpg

关于flv播放,chrome下可以,ie下无效的问题,建议采用 cuplayer
极酷网页视频播放器
http://www.cuplayer.com/cu/download.html
方法是:(也不用费心去修改 kindeditor 的js了)
kindeditor: 会生成如下的html代码
<embed src="/upload/media/20121104/20121104002745_401.flv" type="application/x-shockwave-flash" width="550" height="400" autostart="false" loop="true" />
在往文件或者数据库中保存之前,直接搜索 [x-shockwave-flash], 发现了后,用 cuplayer 的播放源码替换 就可以了
[


<!--酷播迷你 CuPlayerMiniV2.0 代码开始-->
<embed src="/CuPlayer/CuPlayerMiniV22_Black_S.swf" flashvars="&CuPlayerFile=http://vkpws.video.qq.com/flv/47/189/7EJ4HYU2V3r.flv&CuPlayerImage=/CuPlayer/Images/flashChangfa2.jpg&CuPlayerWidth=560&CuPlayerHeight=330&CuPlayerAutoPlay=false&CuPlayerAutoRepeat=true&CuPlayerShowControl=false&CuPlayerAutoHideControl=false&CuPlayerAutoHideTime=5&CuPlayerVolume=80" quality="high" allowfullscreen="true" 
 pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="560" height="330"></embed>
<!--酷播迷你 CuPlayerMiniV2.0 代码结束-->

]
or
[

<!--酷播迷你 CuPlayerMiniV2.2 代码开始-->
<script type="text/javascript" src="Images/swfobject.js"></script>
<div id="CuPlayer" > <strong>酷播迷你(CuPlayerMiniV2.2) 提示:您的Flash Player版本过低,请<a href="http://www.CuPlayer.com/" >点此进行播放器升级</a>!</strong> </div>
<script type=text/javascript>
var so = new SWFObject("/CuPlayer/CuPlayerMiniV22_Black_S.swf","CuPlayer","525","320","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
so.addVariable("CuPlayerFile","http://vkpws.video.qq.com/flv/47/189/7EJ4HYU2V3r.flv");
so.addVariable("CuPlayerImage","/CuPlayer/Images/flashChangfa2.jpg");
so.addVariable("CuPlayerLogo","/CuPlayer/Images/mylogo.png");
so.addVariable("CuPlayerShowImage","true");
so.addVariable("CuPlayerWidth","525");
so.addVariable("CuPlayerHeight","320");
so.addVariable("CuPlayerAutoPlay","true");
so.addVariable("CuPlayerAutoRepeat","false");
so.addVariable("CuPlayerShowControl","true");
so.addVariable("CuPlayerAutoHideControl","false");
so.addVariable("CuPlayerAutoHideTime","6");
so.addVariable("CuPlayerVolume","80");
so.write("CuPlayer");
</script>
<!--酷播迷你 CuPlayerMiniV2.2 代码结束-->





1.
jsp/upload_json.jsp:[

//文件保存目录路径
String savePath = pageContext.getServletContext().getRealPath("/") + "attached/";
//文件保存目录URL
String saveUrl  = request.getContextPath() + "/attached/";
...
HashMap<String, String> extMap = new HashMap<String, String>();
...
//最大文件大小
long maxSize = 1000000;
...
//检查扩展名
if(!Arrays.<String>asList(extMap.get(dirName).split(",")).contains(fileExt)){
out.println(getError("上传文件扩展名是不允许的扩展名。\n只允许" + extMap.get(dirName) + "格式。"));
return;
}
...
obj.put("error", 0);
...
obj.put("error", 1);


-- 上面修改为下面:
 
//文件保存目录路径
String savePath = pageContext.getServletContext().getRealPath("/") + "upload"+ java.io.File.separator;
//文件保存目录URL
String saveUrl  = request.getContextPath() + "/upload/";
// 其中 [upload] 是你www发布目录下,例如 d:\xiaojinta.com\www\upload, 此目录要事先存在, 用于存放上传的文件
// 这样写法,resin 和 tomcat 均运行正常
...
// HashMap<String, String> extMap = new HashMap<String, String>();
Hashtable extMap = new Hashtable();
...
//最大文件大小
long maxSize = 100 * 1000 * 1000L; // 100M
...
String s后缀集合= (String)extMap.get(dirName);
// if( ! Arrays.<String>asList(extMap.get(dirName).split(",")).contains(fileExt) )
if( (","+ s后缀集合 +",").indexOf(","+ fileExt +",") < 0 )
{
out.println(getError("上传文件扩展名是不允许的扩展名。\n只允许" + s后缀集合 + "格式。"));
return;
}
...
obj.put("error", new Integer(0) );
...
obj.put("error", new Integer(1) );




]


2.
jsp/demo.jsp:[


<script>
KindEditor.ready(function(K) {
...
prettyPrint();

-- 上面修改为下面:


<script>
var ed; // 增加此句, 目的是方便后面调用
KindEditor.ready(function(K) {
...
ed= editor1; // 增加此句, 目的是方便后面调用
prettyPrint();
...

然后在页面 最后面 增加下面两句
<br><button onclick="var s= ed.text(); /* 纯文本内容 */ alert(s);">test 获取纯文本 </button>
<br><button onclick="var s= ed.html(); /* 超文本内容 */ alert(s);">test 获取超文本 </button>
]




3.
file_manager_json.jsp:[


//根目录路径,可以指定绝对路径,比如 /var/www/attached/
String rootPath = pageContext.getServletContext().getRealPath("/") + "attached/";
//根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/
String rootUrl  = request.getContextPath() + "/attached/";
...
if(!Arrays.<String>asList(new String[]{"image", "flash", "media", "file"}).contains(dirName))



-- 上面修改为下面:

//文件保存目录路径
String rootPath = pageContext.getServletContext().getRealPath("/") + "upload"+ java.io.File.separator;
//文件保存目录URL
String rootUrl  = request.getContextPath() + "/upload/";


// tomcat 支持,老版resin不支持
// if(!Arrays.<String>asList(new String[]{"image", "flash", "media", "file"}).contains(dirName))
if( (";image;flash;media;file;").indexOf(";"+ dirName +";") < 0 ) // 可兼容老的jsp服务器





]


需要上面已经改好的文件包,请与我联系, 刘涛 qq: 30234923

http://xiaojinta.com/download/kde_02_kindeditor-4.1.3_modified.zip
 
OK,至此全部搞定,感谢 kindeditor 的作者对 软件界的贡献. 





发表新帖 发表回复