项目中要用到fckeditor2.5.1 的上传图片和上传视频功能,网上收集了不少资料,发现综合起来才能解决我这个版本的问题.为了避免大家以后浪费不必要的时间,特将相关方法总结如下:
上传图片:
1.使用“插入图像”或“插入文件”时,单击“浏览服务器”,出现错误:this connector is disabled.please check the "editor/filemanager/connectors/aspx/config.aspx" file.
解决方法:在config.aspx文件中,有一个选项.
private bool CheckAuthentication()
 {
return false ;
 }
默认为false,改为true即可正常使用”浏览服务器”了。
 
2.使用”插入图像”、“插入flash”中的浏览上传和直接上传,都正常。但是使用“插入超链接”时,发现使用浏览上传正常,但是使用直接上传,就提示:Invalid request,百思不得其解,网上查了半天,也没人遇到过。后然偶然在浏览fckconfig.js文件时,发现了问题。
fckconfig.js中,比较linkupload和p_w_picpathuplink后,发现:
FCKConfig.LinkUpload = true ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension ;
FCKConfig.ImageUpload = true ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ;
在ImageUpload最后,有Type=Image参数,而LinkUpload中却没有,先尝试加上Type=Link,失败,再尝试加上Type=File后,成功了。所以问题出在少了参数“ Type=File”。
 
3、"editor/filemanager/connectors/aspx/config.aspx"中有个参数:UserFilesPath = "/userFiles/";,应该改成与web.config中UserFilesPath一样的用户文件上传路径。UserFilesAbsolutePath=""同上面一样改(但是UserFilesAbsolutePath参数做什么用,我还是不太清楚,请知道的高手指点下)
 
4、使用中发现,浏览上传的文件会自动按照类别来传,如图像传在p_w_picpath中,文件传在file中。但是使用直接上传则全部传在上传文件夹的根目录下,研究后发现,只要改动/aspx/config.aspx中的TypeConfig[ "File" ].QuickUploadPath就可以了,改成和TypeConfig[ "File" ].FilesAbsolutePath一样即可。
 
上传视频:
1.分别打开:editor/js/fckeditorcode_ie.js和/editor/js/fckeditorcode_gecko.js
将D.src.endsWith('.swf',true)替换成D.srD.endsWith('.swf',true) || D.srD.endsWith('.mpg',true) || D.srD.endsWith('.asf',true) || D.srD.endsWith('.wma',true) || D.srD.endsWith('.wmv',true) || D.srD.endsWith('.avi',true) || D.srD.endsWith('.mov',true) || D.srD.endsWith('.mp3',true) || D.srD.endsWith('.rm',true) || D.srD.endsWith('.ra',true) || D.srD.endsWith('.rmvb',true) || D.srD.endsWith('.mid',true) || D.srD.endsWith('.ram',true)
2.打开/editor/dialog/fck_flash/fck_flash.js文件
1、增加程序代码
function WinPlayer(url){
    var r, re;
    re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;
    r = url.match(re);
    return r;
}
function RealPlayer(url){
    var r, re;
    re = /.(.rm|.ra|.rmvb|ram)$/i;
    r = url.match(re);
    return r;
}
function QuickTime(url){
    var r, re;
    re = /.(mov|qt)$/i;
    r = url.match(re);
    return r;
}
function FlashPlayer(url){
    var r, re;
    re = /.swf$/i;
    r = url.match(re);
    return r;
}

3. 替换两个地方的代码:一个在UpdatePreview()中,将:
SetAttribute( e, 'type', 'application / x - shockwave - flash' ) ;
替换为:
if (WinPlayer(GetE('txtUrl').value) != null )

SetAttribute( e, 'type', 'application
/x-mplayer2' ) ; 

}
 

if (RealPlayer(GetE('txtUrl').value) != null )

SetAttribute( e, 'type', 'audio
/x-pn-realaudio-plugin' ) ; 

}
 

if (QuickTime(GetE('txtUrl').value) != null )

SetAttribute( e, 'type', 'application
/video/quicktime' ) ; 

}
 

if (FlashPlayer(GetE('txtUrl').value) != null )

SetAttribute( e, 'type', 'application
/x-shockwave-flash' ) ; 

SetAttribute( e, 'pluginspage', 'http:
//[url]www.macromedia.com/go/getflashplayer[/url]' ) ; 

}


4.另一个地方在UpdateEmbed()中,将:
SetAttribute( e, 'type' , 'application / x - shockwave - flash' ) ;

SetAttribute( e, 'pluginspage' , 'http:
// [url]www.macromedia.com/go/getflashplayer[/url]' ) ;
替换为:
if (WinPlayer(GetE('txtUrl').value) != null ) {

SetAttribute( e, 'type' , 'application
/x-mplayer2' ) ; 

SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked 
? 'true' : 'false' ) ;

}


if (RealPlayer(GetE('txtUrl').value) != null ) {

SetAttribute( e, 'type' , 'audio
/x-pn-realaudio-plugin' ) ; 

SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked 
? 'true' : 'false' ) ;

}


if (QuickTime(GetE('txtUrl').value) != null ) {

SetAttribute( e, 'type' , 'video
/quicktime' ) ; 

SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked 
? 'true' : 'false' ) ;

}


if (FlashPlayer(GetE('txtUrl').value) != null ) {

SetAttribute( e, 'type' , 'application
/x-shockwave-flash' ) ;

SetAttribute( e, 'pluginspage' , 'http:
//[url]www.macromedia.com/go/getflashplayer[/url]' ) ;

}

 
5.打开/fckconfig.js文件,将:
FCKConfig.FlashUploadAllowedExtensions  =   " .(swf)$ "  ;  //  empty for all
替换为:
FCKConfig.FlashUploadAllowedExtensions  =   " .(swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid)$ "  ;  //  empty for all
      到此,基本功能已经完成。剩下的是一些细节的设置。
6. 其他设置
6.1 编辑框中文字的设置:打开/editor/lang/zh-cn.js 文件,将flash替换成想要显示的文字。
6.2 默认的音频视频播放效果是循环、自动播放、带操作menu的样式,可以通过设置来显示成想要的效果。方法还是在/editor/dialog/fck_flash/fck_flash.js文件,在UpdateEmbed()方法中,将对应的文件格式中的,
SetAttribute( e, 'play', GetE('chkAutoPlay').checked  ?  ' true ' : ' false ' )
替换为:

SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked 
?  ' false ' : ' true ' ) ;
 
其中注意fckeditor\editor\filemanager\connectors\aspx下的config.ascx文件,里面的内容牵涉到上传路径的问题,不难,仔细阅读即可.