1:下载地址:http://sourceforge.net/projects/fckeditor/files/
2:FCKeditor 2.6在ASP.NET中的配置方法
    配置方法如下:

  一、在官方网站上下载

  下载地址:http://sourceforge.net/project/downloading.php?group_id=75348&filename=FCKeditor_2.6.zip

  解压后目录结构如下图所示:

FCKeditor 2.6在ASP.NET中的配置方法(附源码下载)

  二、删除不必要的文件

  从官方下载下来的FCKEditor2.6大小有3.61M(解压后),其实有很多文件对于只用ASP.NET的来讲是不需要的,我们可以删除不必要的文件:

  1.根目录下除editor目录、fckconfig.js、fckeditor.js fckstyles.xml fcktemplates.xml 这几个保留,其余的全部删除

  2.editorfilemanagerconnectors目录中除aspx目录外全部删除

  3.editorlang目录中除en.js、zh.js 、zh-cn.js外全部删除

  4.删除_samples目录,当然如果你想看示例,就不要删除这个目录了。

  三、FCKEditor2.6的详细设置

  1.fckconfig.js中修改

  FCKConfig.ToolbarSets["Default"] = [
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','ShowBlocks','-','About'] // No comma for the last row.
] ;
  //上面一段我去掉了一些不常用的功能,可以根据实际需要增加。
FCKConfig.DefaultLanguage = 'zh-cn' ; //原来是en
var _FileBrowserLanguage = 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py 改成aspx
var _QuickUploadLanguage = 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py

  2.在Bin中加入DLL文件

  DLL文件下载地址:http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=137125

  3.在工具栏中加入DLL文件

  4.配置上传路径

  编辑FCKeditoreditorfilemanagerconnectorsaspxconfig.aspx 中修改

  private 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 in your system.
return true; //原来这里是 false;不过还是建议看看上面的警告
}

  在SetConfig方法中设置

  UserFilesPath = "~/Upload/FCKEditor";//我这里设置在了网站根目录下的Upload/FCKEditor目录中,根据实际情况和个人喜好而定

3:文件上传操作

 安装 

安装就不多说了,除了一般的那个压缩包外,ASP.NET版的FCKeditor另有一个FCKeditor.Net下载包,里面有一个Visual Studio的Solution,bin/Release里有一个FredCK.FCKeditorV2.dll文件,可以直接COPY到你的ASP.NET项目的bin文件夹里。 

2,附件上传流程 

FCKeditor通过在编辑界面点击Link或图片按钮打开一个模态对话框,在里面选择本地文件后上传。 

这个对话框是Fckeditor/editor/dialog/fck_image.html或fck_link.html。 

对话框的js代码在fck_image和fck_link目录里,它们还会调用common/fck_dialog_common.js 

上面这些都是客户端的事。 

在Fckeditor/editor/filemanager/upload/aspx下有一个孤独的upload.aspx,里面除了注释外只有一句话,它的code behind 的代码是在前面那个ASP.NET下载包里的Uploader.cs,已经被编译进FredCK.FCKeditorV2.dll了。 

3.修改Uploader.cs 

3.1 把upload.aspx上唯一的那行代码修改一下。 

原版:< %@ page autoeventwireup="false" inherits="FredCK.FCKeditorV2.Uploader" language="c#" % > 

修改为:< % @ page autoeventwireup="false" codefile="upload.aspx.cs" inherits="FCKUpload" language="c#" % > 

这样,upload.aspx就不再去FredCK.FCKeditorV2.dll寻找自己的behind code,而是在自己身边找. 

3.2 从FCKeditor.Net压缩包里提取出Uploader.cs,放在自己的ASP.NET项目的FCKeditor目录里和upload.aspx放在一起。这样,Uploader.cs就成了你的项目中的一部分,完全在你的控制之下。 

打开Uploader.cs,里面代码并不复杂。 

首先,你应该加上自己的身份验证。 

然后,HttpPostedFile oFile = Request.Files["NewFile"];,获得上传文件,FCKeditor的客户应当是一次只上传一个,不必考虑多个同时上传的情况。 

获得文件大小,oFile.ContentLength。 

获得文件名,HttpContext.Current.Request.Files[0].FileName, 

要检查后缀的话,System.IO.Path.GetExtension(FileName); 

保存起来,oFile.SaveAs(sFilePath);文件名和路径完全在你的控制中。 

最后通过SendResults把错误代码发回去,如果上传成功,可以发0,然后是文件名和文件URL。 

3.3客户端 

如果有兴趣,可以研究修改一下客户端的那些JS。 

4.部署 

解压缩FCKeditor.Net压缩包,打开里面的Solution,删掉Uploader.cs,重新编译FredCK.FCKeditorV2.dll,新的dll会小一点,在我这儿是从36K变成32K。(注意要编译成Release版)。 

最后用新的dll替换自己的项目里的老的dll。

本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/18675.htm

其中2和3分别依次引用:

http://tech.ddvip.com/2008-09/122232690670750.html

http://www.jb51.net/article/18675.htm

posted on 2009-07-20 11:08  博弈无涯  阅读(476)  评论(0)    收藏  举报