web开发1-fckeditor部署报错:The server didn't reply with a proper XML data.

本文介绍了解决FCKEditor在部署过程中遇到的图片上传问题,详细分析了错误产生的原因并给出了正确的配置方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在部署fckeditor的时候可能遇到各种各样的问题,很容易就在网上搜到答案的可能大家不会在乎,我遇到的纠结了很长时间在搞定,走了一些弯路。

先看看问题。部署好之后上传图片的时候浏览本地文件的时候出错。火狐错误界面如下图1

图1

这个图给的信息是假象,通过信息可以找到报错的代码\fckeditor\editor\filemanager\browser\default\js\fckxml.js,

代码如下:

FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
{
    var oFCKXml = this ;

    var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;

    var oXmlHttp = this.GetHttpRequest() ;

    oXmlHttp.open( "GET", urlToCall, bAsync ) ;

    if ( bAsync )
    {
        oXmlHttp.onreadystatechange = function()
        {
            if ( oXmlHttp.readyState == 4 )
            {
                var oXml ;
                try
                {
                    // this is the same test for an FF2 bug as in fckxml_gecko.js
                    // but we've moved the responseXML assignment into the try{}
                    // so we don't even have to check the return status codes.
                    var test = oXmlHttp.responseXML.firstChild ;
                    oXml = oXmlHttp.responseXML ;
                }
                catch ( e )
                {
                    try
                    {
                        oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
                    }
                    catch ( e ) {}
                }

                if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
                {
                    alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
                            'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
                            'Requested URL:\n' + urlToCall + '\n\n' +
                            'Response text:\n' + oXmlHttp.responseText ) ;
                    return ;
                }

                oFCKXml.DOMDocument = oXml ;
                asyncFunctionPointer( oFCKXml ) ;
            }
        }
    }

    oXmlHttp.send( null ) ;

    if ( ! bAsync )
    {
        if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
            this.DOMDocument = oXmlHttp.responseXML ;
        else
        {
            alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
        }
    }
}

在网上很多人在这段代码里面找原因,围绕着这一段代码修改,并且解决了问题 ,但是很不幸,除了我之外,我也在这段代码里面缝缝补补,最后问题还是存在。

在IE浏览器里面报错更加详细,其实在火狐里面如果跟进去也可以看到这个详细的报错信息,如下图2。

图2

最关键的信息是:Error calling [msvcrt.dll]:_wnkdir(c:\input\wwwroot\fckfiles),error code:-1
注意到fckfiles是我自己新建的一个文件夹,放在和fckeditor平行的一个目录下,怎么会出现在“c:\input\wwwroot\fckfiles”这样的一个路径下呢,很明显是配置文件里面配置上传图片文件的目录时出错了。

将<add key="FCKeditor:UserFilesPath" value="/fckfiles/"/>修改为<add key="FCKeditor:UserFilesPath" value="~/fckfiles/"/>最后解决问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值