FCKEDITOR

项目需要在线HTML编辑器,就选择了FCKeditor,目前最新是2.5Bate,不过稳定点定还是选了2.4.3,而.net的控件还是2.2没变过 [smile] ,大概如何使用见我之前的“FCKeditor 2.3 在ASP.NET中文件上传路径的设置”,关于它的配置如:界面布局啊什么的网上去搜索下,太多了,就不写了 [smile] 
  FCKeditor在web.config中有多项设置:
view plaincopy to clipboardprint?
<appSettings>  
<!--FCKeditor设置(主要是以下两项)-->  
<!--FCKeditor编辑器路径-->  
<add key="FCKeditor:BasePath" value="/FCKeditor/"/>  
<!--FCKeditor用户附件上传路径-->  
<add key="FCKeditor:UserFilesPath" value="/Resources/TempUpload/"/>  
</appSettings>  
  用户登录后通过FCKeditor上传文件则要放置在用户共用上传路径“/Resources/UserUpload/”+“用户邮箱地址”,如“/Resources/UserUpload/user@gmail.com”。FCKeditor.net获取上传路径文件是:FileWorkerBase.cs,打开找到以下部分
view plaincopy to clipboardprint?
 protected string UserFilesPath  
    {  
      get  
      {  
        if ( sUserFilesPath == null )  
        {  
          // 第一回从Application["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式  
          sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;  
  
          // 第二回从Session["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式  
          if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )  
          {  
            sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;  
              
            // 第三回从web.config中读取,如果没有尝试其它方式  
            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )  
            {  
              sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;  
                
              // 第四回从DEFAULT_USER_FILES_PATH(这个变量在同文件中)中读取,如果没有尝试其它方式  
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
                sUserFilesPath = DEFAULT_USER_FILES_PATH ;  
  
              // 第五回从网址参数ServerPath中读取  
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
              {  
                sUserFilesPath = Request.QueryString["ServerPath"] ;  
              }  
  
            }  
          }  
  
          // Check that the user path ends with slash ("/")  
          if ( ! sUserFilesPath.EndsWith("/") )  
            sUserFilesPath += "/" ;  
        }  
        return sUserFilesPath ;  
      }  
    }  
  从上面的注释可以看到用户上传路径的顺序,只要在页面加载的时候设置下Session["FCKeditor:UserFilesPath"]就可以设置FCKeditor上用户上传路径了
view plaincopy to clipboardprint?
protected void Page_Load(object sender, EventArgs e)  
{  
 if (!Page.IsPostBack)  
 Session["FCKeditor:UserFilesPath"] = "用户上传路径";  
}  
  (我在配置的时候关闭了文件浏览,只提供文件快速上传)但是在使用的时候如果“Resources/UserUpload/user@gmail.com”中的user@gmail.com路径没创建,上传中FCKeditor它不会创建,也导致了文件无法上传成功,那就需要再修改FCKeditor.net项目中的Uploader.cs文件,添加一段文件夹存在的检测代码,如果不存在用户指定的文件夹侧创建一个
view plaincopy to clipboardprint?
// Get the uploaded file name.  
string sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;  
  
int iCounter = 0 ;  
  
//景裔添加  
//检查上传目录是否已经被创建  
//开始==========================================  
//检查当前完整路径是否存在,不存在则开始逐级轮询检查,不存则就创建  
if (!System.IO.Directory.Exists(UserFilesDirectory))  
{  
string[] tempDirectorys = UserFilesDirectory.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries); 
string tempDirectory = string.Empty; 
for (int i = 0; i < tempDirectorys.Length; i++) 

tempDirectory += tempDirectorys[i] + "\\"; 
if (!System.IO.Directory.Exists(tempDirectory)) 
System.IO.Directory.CreateDirectory(tempDirectory); 


//结束========================================== 
 
while ( true ) 

string sFilePath = System.IO.Path.Combine( this.UserFilesDirectory, sFileName ) ; 
 
if ( System.IO.File.Exists( sFilePath ) ) 

iCounter++ ; 
sFileName =  
System.IO.Path.GetFileNameWithoutExtension( oFile.FileName ) + 
"(" + iCounter + ")" +  
System.IO.Path.GetExtension( oFile.FileName ) ;  
  
iErrorNumber = 201 ;  
}  
else  
{  
oFile.SaveAs( sFilePath ) ;  
  
sFileUrl = this.UserFilesPath + sFileName ;  
break ;  
}  
}  
  这样就基本解决了多用户分文件夹上传图片的问题,不过也有缺陷的地方,就是当用户Session超时的时候,用户再使用浏览器上传文件就不会按照指定用户文件夹上传来了,分析这个情况可以得出:这个时候用户通过编辑器上传的文件也就是对编辑器内容作出了修改,但是因为Session超时了,所以可以把做出的修改视作无效,既然修改无效,那用户上传的文件也是没用的,所在我在web.config中又设置了个默认文件上传位置,所有无效文件都会上传到这里,那个回清理的时候也方便多了 [lol] 不知道哪位大虾还有更好的办法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值