FckEditor 2.6.4升级手记
说是升级,其实就是把原来的版本替换掉
1.先到www.fckeditor.net上下载fckeditor(html/js包)和fckeditor.net(专用于aspx环境中处理上传的dll包)
2.将fckeditor中"_"开头的文件都删除掉(基本上都是源码和说明性文档,没啥用处)
3.修改fckconfig.js
FCKConfig.DefaultLanguage = 'zh-cn' ; //改为简体中文 ... var _FileBrowserLanguage = 'aspx' ; // 设置上传处理的服务端语言 var _QuickUploadLanguage = 'aspx' ; // 设置上传处理的服务端语言
4.上传处理
打开 editorfilemanagerconnectorsaspxconfig.ascx
修改CheckAuthentication(),这里我改为仅登录后才能上传(当然你可以根据自己的要求来修改,甚至直接返回true都可以,不过这样会有安全问题,任何人都可以直接上传)
private bool CheckAuthentication()
{
//return false;
return HttpContext.Current.User.Identity.IsAuthenticated;
}
5.扩展FredCK.FCKeditorV2.dll
默认情况下,fckeditor上传后的文件名是不会自动重命名的,而且默认上传后的文件全部在一个目录下,另外不知道为何,2.6.4中居然去掉了上传文件最大尺寸的限制
好了,一一处理,打开FCKeditor.Net_2.6.3.zip下载包中的解决方案
FileBrowserFileWorkerBase.cs 修改
protected void FileUpload( string resourceType, string currentFolder, bool isQuickUpload )
{
HttpPostedFile oFile = Request.Files[ "NewFile" ];
string sFileName = "";
if ( oFile == null )
{
this.SendFileUploadResponse( 202, isQuickUpload );
return;
}
//检测文件大小
int _postFileSize = 0;
if (_postFileSize < 1)
{
if (Request.Cookies["FCKeditor:UserUploadSize"] != null)
{
_postFileSize = Convert.ToInt32(this.Request.Cookies["FCKeditor:UserUploadSize"].Value);
}
if (_postFileSize < 1)
{
_postFileSize = Convert.ToInt32(base.Application["FCKeditor:UserUploadSize"]);
if (_postFileSize < 1)
{
_postFileSize = Convert.ToInt32(this.Session["FCKeditor:UserUploadSize"]);
if (_postFileSize < 1)
{
_postFileSize = Convert.ToInt32(ConfigurationManager.AppSettings["FCKeditor:UserUploadSize"]);
if (_postFileSize < 1)
{
_postFileSize = 500;//默认500k大小
}
}
}
}
}
if (oFile.ContentLength > _postFileSize * 1024)
{
this.SendFileUploadResponse(101, isQuickUpload,"","","上传文件不得超过 " + _postFileSize + " K");
return;
}
// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder( resourceType, currentFolder, isQuickUpload );
// Get the uploaded file name.
sFileName = System.IO.Path.GetFileName( oFile.FileName );
sFileName = this.SanitizeFileName( sFileName ).ToLower();
string sExtension = System.IO.Path.GetExtension( oFile.FileName );
sExtension = sExtension.TrimStart( '.' ).ToLower();
//强制把文件名改成Guid.ext形式(当然你也可以自行另定义规则,比如常用的yyyymmddssffff格式)
sFileName = NewComb().ToString().ToLower() + "." + sExtension;
...
}
Config.cs修改
internal void LoadConfig()
{
DefaultSettings();
// Call the setConfig() function for the configuration file (config.ascx).
SetConfig();
//上传目录设置,优化级cookie>session>application>web.config
//Cookie
// Look for possible UserFilesPath override options.
string userFilesPath = null;
if (HttpContext.Current.Request.Cookies["FCKeditor:UserFilesPath"] != null)
{
userFilesPath = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["FCKeditor:UserFilesPath"].Value);
}
// Session
if (userFilesPath == null || userFilesPath.Length == 0)
{
userFilesPath = Session["FCKeditor:UserFilesPath"] as string;
}
// Application
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = Application[ "FCKeditor:UserFilesPath" ] as string;
// Web.config file.
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = System.Configuration.ConfigurationSettings.AppSettings[ "FCKeditor:UserFilesPath" ];
// config.asxc
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = this.UserFilesPath;
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = DEFAULT_USER_FILES_PATH;
// Check that the user path ends with slash ("/")
if ( !userFilesPath.EndsWith( "/" ) )
userFilesPath += "/";
userFilesPath = this.ResolveUrl( userFilesPath );
//改为自动按yyyy/mm/dd格式生成上传目录
userFilesPath += DateTime.Now.Year.ToString().PadLeft(4, '0') + "/" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Day.ToString().PadLeft(2, '0') + "/";
this.UserFilesPath = userFilesPath;
}
源代码下载: http://files.cnblogs.com/yjmyzz/fck2.6.4_Full.rar
说明:解压后zip为原始未做任何修改的版本,AspxDemo里为修改过后的示例
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 从源代码级别看懂MinIO对象存储网关的实现
- 4种主流超参数调优技术
- 一分钟学Python| 面向对象(上)
- Python 为什么不支持 switch 语句?
- 你还在认为 count(1) 比 count(*) 效率高?
- 一分钟学Python| 面向对象(中)
- uni-app自定义打包目录package.json命令配置
- 在Zeppelin中如何使用Hive
- B站真题:如何判断括号是否有效?
- (在模仿中精进数据可视化03)OD数据的特殊可视化方式
- Ubuntu20.04 体验和美化
- hadoop重用机制
- hadoop搭建完全分布式集群
- 一篇让你搞懂 Nginx
- Feign讲解与应用(文末送书)