CKFinder的集成及上传功能的实现

主要是以下几步

1:web层建立js文件夹以备放ckeditor_3.2文件夹
2:ckeditor_3.2只需要adapters images lang plugins skins themes ckeditor.js
contents.css config.js将他们解压到JS下ckeditor文件夹里 ,如果全部放的话有一定的安全隐患
3:在ASPX文件中添加textbox设置 TextMode="MultiLine"
4:把ckeditor.js拖入aspx文件中
5:设置textbox 的cssclass属性为CssClass="ckeditor"
6:这时候可以显示了 但是提交的时候有问题(检测到有潜在危险的 Request.Form 值)
有两种方法解决是:
    1、在本页开始代码加<% Page …… ValidateRequest="false"……
    2、在web。config里<system.web><page ValidateRequest="false/>……加

    主要就是安全问题。

 

这个时候 出了不能上传外,其他的功能都基本上齐全了然后我们来实现上传文件的功能吧
 (1):上传需要插件的支持ckfinder_aspnet_1.4.3
 (2):ckfinder_aspnet_1.4.3\ckfinder\bin\Debug\CKFinder.dll找出来拷入项目WEB层的第三方类库文件夹中
 (3):web层中添加对CKFinder.dll的引用
 (4) :ckfinder_aspnet_1.4.3文件夹中选择 core  ckfinder.js config.ascx ckfinder.html几
个文件复制到JS下ckfinder文件夹里
 (5):修改ckeditor的config.js文件(注意不是CKFinder),讲上传的处理程序设定为CKFinder,.用以下代码覆盖原来的代码,注意路径问题

代码
CKEDITOR.editorConfig = function(config) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
var ckfinderPath = "/js";
//主要是改这里的路径代码
config.filebrowserBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload
&type=Files';
config.filebrowserImageUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload
&type=Images';
config.filebrowserFlashUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload
&type=Flash';
};

(6)这一步的时候,上传的时候提示我们没提供权限上传,这时候我们要修改CKFinder的config.ascx里的内容

原来的内容

代码
public override bool CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
//
// return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs on your system.

return false;
}

 

如果 login.aspx页面中SESSION["已经登录"]=true;

那么在上面上面代码框在里面添加上一段判断SESSION["已经登录"]的值后代码变为

 

代码
public override bool CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
//
// return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs on your system.
object obj = Session["已经登录"] = true;
if (obj!=null&Convert.ToBoolean(obj)==true)
{
return true;
}
else
{
return false;
}
}

 

posted @ 2011-01-04 17:22  卢青松  阅读(2812)  评论(0编辑  收藏  举报