FCK的上传图片上传到我们指定的目录
来源:互联网 发布:哪个软件看电视节目 编辑:程序博客网 时间:2024/05/02 16:38
比如我们在编辑一篇文章时,,我们总希望FCK的上传图片上传到我们指定的目录,比如按时间.或按ID等等 ;
需要指定路径就得找到FCK上传文件时组合路径的地方.
拿到FCK的.net的源码:FredCK.FCKeditorV2
打开源码目录FileBrowser下的Config.cs文件
就可以看到组合路径方式:
- internal void LoadConfig()
- {
- DefaultSettings();
- // Call the setConfig() function for the configuration file (config.ascx).
- SetConfig();
- // Look for possible UserFilesPath override options.
- string hostname = System.Configuration.ConfigurationSettings.AppSettings["HostName"];
- string userFilesPath = HttpContext.Current.Request.QueryString["userfilespath"];
- if (!string.IsNullOrEmpty(userFilesPath))
- {
- userFilesPath = System.Configuration.ConfigurationSettings.AppSettings[ "FCKeditor:UserFilesPath" ] + userFilesPath.Trim('/');
- }
- // Session
- if (string.IsNullOrEmpty(userFilesPath))
- {
- 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 = string.IsNullOrEmpty(hostname) ? userFilesPath : hostname.TrimEnd('/') + userFilesPath;
- userFilesPath = this.ResolveUrl( userFilesPath );
- this.UserFilesPath = userFilesPath;
- }
相信看这段代码不是难事
string hostname = System.Configuration.ConfigurationSettings.AppSettings["HostName"];
string userFilesPath = HttpContext.Current.Request.QueryString["userfilespath"];
string userFilesPath = HttpContext.Current.Request.QueryString["userfilespath"];
这二项是我加上的..我们就是通过URL来动态传递路径的
因为url传路径不安全.我们还是保留FCK的web.config配置路径的方式...只是我们会在配置:FCKeditor:UserFilesPath目录下再生成我们规则的路径
比如:FCKeditor:UserFilesPath配置为:/WebData/
而我们传的路径为userfilespath=2010/08/09
那么上传文件的路径就是webdata/2010/08/09...这是我们可以动态赋值给FCK的
做到这里还不够..我们得给FCK加个属性可以让我们动态设置路径;
打开源码中的:FCKeditor.cs
找到代码块:#region Configurations Properties
加一个属性在此代码块中:
- [Category("Configurations")]
- public string FileMidPath
- {
- set { ImageBrowserURL = this.EditorPath + "/filemanager/browser/default/browser.html?Type=Image&Connector=" +
- this.EditorPath + "/filemanager/connectors/aspx/connector.aspx?userfilespath=" + value; }
- }
ImageBrowserURL 就是FCK图片浏览的地址;userfilespath就是我们动态设定的路径
现在使用就简单了;
在页面中加上FCK后;在pageload中赋给其路径:这个路径随便你给..GUID等都行.
- protected void Page_Load(object sender, EventArgs e)
- {
- FckContent.FileMidPath = "2010/08/09";
- }
看看效果:
至此完成路径重写了
当然你可以改得更自由..不过安全也很重要
- FCK的上传图片上传到我们指定的目录
- fck配置,以及上传图片到指定的路径
- 文件上传简介1---上传到指定的目录1
- 文件上传简介1---上传到指定的目录2
- 文件上传简介1---上传到指定的目录3
- 文件上传简介1---上传到指定的目录
- 安卓中图片上传到指定的服务器
- FCK Editor 从Word文档粘贴的多个图片上传到服务器
- fck上传图片
- 提取FCK编辑器中上传的图片地址
- FCK上传图片(文件)绝对路径保存的实现
- 利用正则表达式 获取FCK上传的图片
- 用struts上传文件时创建目录以及把文件上传到指定的目录
- 指定上传图片的大小
- FreeTextBox控件上传图片到指定的绝对路径的改进
- FreeTextBox控件上传图片到指定的绝对路径的改进
- 图片文件上传到网站的指定的文件夹
- FCK上传图片,接收图片
- 批量将Java源代码文件的编码从GBK转为UTF-8
- jsp+javabean
- ckeditor3.6.4+ckfinder2.2.2 上传图片到指定
- ScrollView嵌入HorizontalScrollView后滑动卡顿问题
- 单双引号区别
- FCK的上传图片上传到我们指定的目录
- Makefile与shell脚本区别
- Sql语句用left join 解决多表关联问题(关联套关联,例子和源码)
- 浅谈SAP系统的预测模型与预测公式
- InnoDB: Error number 24 means 'Too many open files'.
- js typeof运算符的使用
- android intent 之见解
- spring filter
- .rc error rc2135 file not found .tlb - 解决方法