FCKeditor2.6.3.net的下载及部署

FCKeditor2.6.3.net的下载及部署

explain source: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Integration/ASP.NET

code source FCKeditor2.6.4: http://sourceforge.net/project/downloading.php?group_id=75348&filename=FCKeditor_2.6.4.zip

code source FCKeditor2.6.3 net: http://www.fckeditor.net/download

1. 下载
    FCKeditor_2.6.3.zip(核心文件)
    FCKeditor.Net_2.6.3.zip(。Net Control)

2. 部署到.NET网站中
    //FCKeditor_2.6.3.zip解压后将fck根目录改名为FckTools,放到网站根目录下。(经操作无必要)
    网站根目录下创建一个文件夹FckFiles,用于存放上传的文件
    在网站中引用FCKeditor.Net_2.6.3.zip中的“FredCK.FCKeditorV2.dll”

3. 简化fck配置
    删除所有以_开始的文件和文件夹,在filemanager中的connector中除aspx以外的文件夹

4. 修改fck的语言
    fckeditor中的fckconfig.js
    61~63行
FCKConfig.AutoDetectLanguage    = false ;
FCKConfig.DefaultLanguage        = 'zh-cn' ;
FCKConfig.ContentLangDirection    = 'ltr' ;

5. 修改上传和浏览文件的程序语言类型
    fckeditor中的fckconfig.js
    276~277行

var _FileBrowserLanguage    = 'aspx' ;    // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage    = 'aspx' ;    // asp | aspx | cfm | lasso | perl | php | py

web.config->

    <appSettings>
      <add key="FCKeditor:BasePath" value="/FckTools/"/>
      <add key="FCKeditor:UserFilesPath" value="/FckFiles/" />
    </appSettings>

default.aspx->

<%@ Page Language="C#"%>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sample Page</title>
</head>
<body>
<form id="form1" runat="server">

<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server">
</FCKeditorV2:FCKeditor>

<div>
</div>
<input type="submit" value="Submit" runat="server" />
</form>
</body>
</html>

default.aspx.cs->

empty

upload set->

fckeditor2.6.3默认已经在fckconfig.js中允许被授权的连接上传和浏览文件了,但是默认情况下有将所有的连接都设为了未授权状态。修改方法为修改editor/filemanager/connector/aspx/config.ascx

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;
    }
    找到CheckAuthentication方法,默认情况返回false,这里要改为true。也可以根据登录情况来选择权限检测的返回值。

 

至此,上传设置已经完成!

下面讲一下上传设置的优化:

1. fckeditor的上传有两种方式:quick方式和非quick方式。
    非quick方式是通过单击“浏览服务器”,在“浏览服务器”窗口中上传。这种上传根据上传文件的类型,自动上传到相应的目录,例如图片自动上传到uploadfiles/image下(uploadfiles为用户自己指定);
    quick方式则通过在“上传”选项卡中上传。这种上传直接将文件上传到上传根目录uploadfiles。(uploadfiles为用户自己指定)。
    但是个人认为quick上传不好的地方在于所有上传的文件不分类型都放在根目录,很凌乱。所以考虑将这两种上传方式都按照类型存放到相应的文件夹中。

   修改方法:

方法1:修改filemanager/connectors/aspx/config.ascx

 

        TypeConfig["File"].AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xml", "zip" };
        TypeConfig["File"].DeniedExtensions = new string[] { };
        TypeConfig["File"].FilesPath = "%UserFilesPath%file/";
        TypeConfig["File"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%file/");
        TypeConfig["File"].QuickUploadPath = "%UserFilesPath%file/";
        TypeConfig["File"].QuickUploadAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
    将TypeConfig["File"].QuickUploadPath 的值改为与 TypeConfig["File"].FilesPath相同 = "%UserFilesPath%file/";

方法2:修改FCKeditor.Net_2.6.3源代码(较麻烦)

   (1). 将FCKeditor.Net_2.6.3.zip解压缩,打开解压后的工程,修改FileBrowser/FileWorkerBase.cs

        protected string ServerMapFolder( string resourceType, string folderPath, bool isQuickUpload )
        {
            TypeConfig typeConfig = this.Config.TypeConfig[ resourceType ];

            // Get the resource type directory.
            /*-----------修改前-------------------*/
            //string sResourceTypePath = isQuickUpload ? typeConfig.GetQuickUploadDirectory() : typeConfig.GetFilesDirectory();
            /*------------------------------------*/
            /*-----------修改后-------------------*/
            string sResourceTypePath = typeConfig.GetFilesDirectory();
            /*------------------------------------*/
           
            // Ensure that the directory exists.
            Util.CreateDirectory( sResourceTypePath );

            // Return the resource type directory combined with the required path.
            return System.IO.Path.Combine( sResourceTypePath, folderPath.TrimStart( '/' ) );
        }
    如上面代码,无论isQuickUpload为true或false,都按照非Quick上传方式,取得上传路径(即typeConfig.GetFilesDirectory())。
    (2). 修改fckconfig.js


FCKConfig.LinkBrowser = true ;
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.LinkBrowserWindowWidth    = FCKConfig.ScreenWidth * 0.7 ;        // 70%
FCKConfig.LinkBrowserWindowHeight    = FCKConfig.ScreenHeight * 0.7 ;    // 70%

FCKConfig.ImageBrowser = true ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Image&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.ImageBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ;    // 70% ;
FCKConfig.ImageBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ;    // 70% ;

FCKConfig.FlashBrowser = true ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.FlashBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ;    //70% ;
FCKConfig.FlashBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ;    //70% ;

FCKConfig.LinkUpload = true ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=File';
//FCKConfig.LinkUploadAllowedExtensions    = "" ;            // empty for all
FCKConfig.LinkUploadAllowedExtensions    = ".(7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip)$" ;            // empty for all
FCKConfig.LinkUploadDeniedExtensions    = "" ;    // empty for no one

FCKConfig.ImageUpload = true ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ;
FCKConfig.ImageUploadAllowedExtensions    = ".(jpg|gif|jpeg|png|bmp)$" ;        // empty for all
FCKConfig.ImageUploadDeniedExtensions    = "" ;                            // empty for no one

FCKConfig.FlashUpload = true ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Flash' ;
FCKConfig.FlashUploadAllowedExtensions    = ".(swf|flv)$" ;        // empty for all
FCKConfig.FlashUploadDeniedExtensions    = "" ;                    // empty for no one

      可以看到包括两部分设置:浏览(LinkBrowser、ImageBrowser和FlashBrowser)和上传(LinkUpload、ImageUpload和FlashUpload)。主要是做了如下修改
Code
/*-------修改前------------*/
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension ;
/*-------修改后-----------*/
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=File';

     在最后加上了Type=File,这样通过添加链接上传的文件就上传到了file目录下。
    也可以对FCKConfig.LinkBrowserURL进行修改加上Type=File,这样在点击添加链接里的“浏览服务器”时就只能浏览File目录下的文件和文件夹。可以看到Image和Flash默认时都只能浏览Image和Flash目录,如果去掉Type=Image和Type=Flash就可以浏览上传根目录下的所有目录了。

至此,上传设置就基本完成了。当然还可以对上传做进一步的设置,例如:随机生成文件名;上传目录以year/month/;上传图片加水印等会在以后来贴出来。

-------------------------------------------注意--------------------------------------------------------------------------------

将fck控件拖到页面后一定要看一下控件的一属性:BasePath;

因一般将fck解压缩文件放到项目的根目录下,故BasePath值应改为~/fckeditor/

转载于:https://www.cnblogs.com/cncode/archive/2010/02/19/1669444.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Version 2.5<br>Attention : This version is not compatible with releases before FCKeditor 2.5.1.<br><br>New Features and Improvements:<br><br>[#1548] Compatible with Safari 3.0+ and Opera 9.50+. <br>Added specific project files for Visual Studio .NET 2003 and Visual Studio 2005. It's easier now to open the source in your preferred environment. Builds will end up in the "1.1" (VS2003) and "2.0" (VS2005) folders inside bin/Debug and bin/Release. <br>[#79] The BasePath property now defaults to "/fckeditor/" ("/FCKeditor/" previously). <br>[#79] Introduced the FCKeditor.IsCompatibleBrowser static function, to check if the requesting browser is compatible with FCKeditor. <br>[#79] Introduced the FCKeditor.CreateHtml function, which returns the HTML needed to create an editor instance in the page. <br>[#294] The HtmlEncodeOutput setting is enforced by the editor component, to avoid having to set ValidateRequest="false" on pages using the editor. <br>Several changes to the File Browser and Uploader:<br>Several security checks have been introduced. Upgrading is hightly recommended. <br>The code has been reviewed according to our standards, aligning the FCKeditor.Net File Browser to the same quality and feature level present in other server language implementations of it, like the PHP implementation. <br>The connector can now be fully configured by using the "editor/filemanager/connectors/aspx/config.ascx" file, available with FCKeditor 2.5.1. <br>For file uploads, the file extension is precisely controlled in a list defined in the config.ascx file. <br>It is possible to define different folder locations for each file type. <br>Attention : For security, the connector must be explicitly activated, by setting "Enabled = true" in the config.ascx file. <br>Attention : The default connector path has been changed to "/userfiles/", instead of "/UserFiles/". This change should not impact Windows installations. <br>
FCKeditor 网页文本编辑器ASP.NET FCKeditor是一个功能强大支持所见即所得功能的文本编辑器,可以为用户提供微软office软件一样的在线文档编辑服务。它不需要安装任何形式的客户端,兼容绝大多数主流浏览器,支持ASP.Net、ASP、ColdFusion 、PHP、Java、Active-FoxPro、Lasso、Perl、ython 等编程环境。 主要文件_2.6.6+FCKeditor.Net_2.6.4 引用FredCK.FCKeditorV2.dll .配置WebConfig <configuration> <appSettings> <add key="FCKeditor:BasePath" //编辑器路径 value="~/fckeditor/"/> <add key="FCKeditor:UserFilesPath" value="~/Files/" /> //上传文件路径 </appSettings> <connectionStrings/> <system.web> BasePath:fckeditorFCKeditor整个文件夹所在的目录。 UserFilesPath:上传文件、图片等存储的路径。 调用:FCKeditor1.Value FCKeditor详细的设置  1、配置皮肤。有default、office2003、silver风格等,这里我们可以使用默认。     FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;   2、在编辑器域内可以使用Tab键。(1为是,0为否)     FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ;   3、加上几种我们常用的字体的方法,例如:   修改FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;   改为:FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana'   4、编辑器域内默认的显示字体为12px,想要修改可以通过修改样式表来达到要求,打开/editor/css/fck_editorarea.css,修改font-size属性即可。如font-size: 14px;   5、关于安全性。   FCKConfig.ToolbarSets["Basic"] = [     ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','Image','-','About']   ] ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值