zoukankan      html  css  js  c++  java
  • 应用主题后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!

  • 相关阅读:
    转 JQuery 爱好者们的福音:jQuery EasyUI 开源插件套装 完全替代ExtJS 武胜
    转 自己做的C#版ILMerge,可将所有引用的DLL和exe文件打成一个exe文件,有图解 武胜
    关于文件结束符EOF feof 区别
    OpenLDAP中文版帮助文件(转)
    文件结束符EOF .
    VMware中Linux系统网络配置
    Python 字符串格式化输出(format/printf)
    李彦宏创业12年解读:企业家精神改变工程师命运
    gcc命令行详解
    如何成为一名 Google 软件工程师?
  • 原文地址:https://www.cnblogs.com/itelite/p/947755.html
Copyright © 2011-2022 走看看