应用主题后FCKeditor上传问题的解决及相应的改进

在Freetextbox收费后没有选择只能选用了FCKeditor。初步使用非常方便,而且对于配置2.3比2.2改进很多。之用将fckconfig.js中的
var _FileBrowserLanguage = 'aspx' ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'aspx' ; // asp | aspx | cfm | lasso | php
改成aspx就可以了。比起原来2.2好很多。

可是上传一直搞不定,于是多次向Truly告急!在他的帮助下设置了
Application["FCKeditor:UserFilesPath"]
这个性能可能是最高的,因为如果您下载了FCKeditor.Net的话你会在FileWorkerBase.cs里面发现如下代码

 1protected string UserFilesPath
 2        {
 3            get
 4            {
 5                if ( sUserFilesPath == null )
 6                {
 7                    // Try to get from the "Application".
 8                    sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;
 9
10                    // Try to get from the "Session".
11                    if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
12                    {
13                        sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;
14                        
15                        // Try to get from the Web.config file.
16                        if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
17                        {
18                            sUserFilesPath = System.Configuration.ConfigurationManager.AppSettings["FCKeditor:UserFilesPath"] ;
19                            
20                            // Otherwise use the default value.
21                            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 ) 
22                                sUserFilesPath = DEFAULT_USER_FILES_PATH ;
23
24                            // Try to get from the URL.
25                            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 ) 
26                            {
27                                sUserFilesPath = Request.QueryString["ServerPath"] ;
28                            }

29                        }

30                    }

31
32                    // Check that the user path ends with slash ("/")
33                    if ( ! sUserFilesPath.EndsWith("/") )
34                        sUserFilesPath += "/" ;
35                }

36                return sUserFilesPath ;
37            }

38        }


所以在Global.asax的Application_Start事件中添加Application["FCKeditor:UserFilesPath"]是最好的处理方法。

但是经过多天的测试和改进还是不能上传。

多次无奈后最终继续向Truly告急,动用了最昂贵的方法——电话,希望Truly那边不是双向收费!

Truly告诉我只能把FCKeditor.net加入项目调试!
于是加入项目调试,可是……还是无用,设置了N多的断点,可是根本没有用!

就在这个时候我突然发现在\FCKeditor\editor\filemanager\upload下面有一个test.html
打开后发现是一个Upload的调试页面,而且很方便。只要选择aspx就可以了,可以看到POST页面的过程。
赶快调试,错误一堆!正无奈的时候突然发现我没有将这个文件放置到项目文件里面,还在解压包里面,于是拷贝到项目里面,调试,提示请求
<head runat="server">
错误!
突然想到了主题!我应用的主题,主题写入可是要在<head>里面加载东西的啊!
于是打开\FCKeditor\editor\filemanager\upload\aspx\Upload.aspx文件,在页面加入
<html>
<head runat="server">
</head></html>
代码,调试……紧张啊!
突然弹出来一个英文提示!不会又错误了吧!仔细一看!提示的信息是上传文件成功!

终于找到了问题的所在!

总结一下,在根据项目精简FCKeditor的时候不要把所有无关的文件都删除,像FCKeditor\editor\filemanager\upload下面有一个test.html这么好的调试东西怎么可以不用呢?有的时候源码设置断点也是没有用的,像这个主题引起的问题。

还有,由于在设计的时候目录放的很多,所以对于图片的相对路径就出现了问题,我在Global.asax的Application_Start事件里面是这样写的
Application["FCKeditor:UserFilesPath"] = "~/UploadFiles/UserFiles/";
本来是写成
Application["FCKeditor:UserFilesPath"] = "/UploadFiles/UserFiles/";
结果出现找不到路径,后来发现是相对目录的问题。于是改成了上面的。可是问题又来了,上传成功后给我返回的html编码是这样的
<img src="~/UploadFiles/UserFiles/******.***>。这样还是不能显示,于是找到了控制伤处的基类Uploader.cs改之

sFileUrl = this.UserFilesPath + sFileName ;
改成
sFileUrl = Request.ApplicationPath + this.UserFilesPath.Replace("~","") + sFileName ;

结果大家都知道了吧!一切正常!
好了,问题最终很好的解决了!再次谢谢Truly!

posted @ 2007-11-03 11:16  东风125  阅读(348)  评论(0编辑  收藏  举报