整合CKEditor与ckfinder的注意点

环境说明

使用的环境是VS2010,.Net4.0,XP,IE8.0, CKEditor.Net 3.6.2,CKFinder2.1.1

文件准备

CKEditor复制_Sample目录下ckeditor目录到网站根目录

CKFinder复制ckfinder目录后删除里面的_sample目录,_source,bin等目录与.txt文件

调整代码

调整CKFinder,FileUploadCommandHandler.cs中的SendResponse方法中的代码

HttpPostedFile oFile = HttpContext.Current.Request.Files[HttpContext.Current.Request.Files.AllKeys[0]];

改为-->

if (HttpContext.Current.Request.Files.Count <= 0) return;
    HttpPostedFile oFile = HttpContext.Current.Request.Files[0];

因为这句老报错,端点后发现有时是Files集合为空造成的

配置整合

引用CKEditor.Net.dll与CKFinder.dll,另外在工具箱中加入CKEditor

在页面初始化(一般是Page_Load)中加入以下代码,使CKEditor启用文件上传功能

        CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
        _FileBrowser.BasePath = "/ckfinder/";
        _FileBrowser.SetupCKEditor(CKEditor1);

原文地址:https://www.cnblogs.com/wdfrog/p/2409531.html