zoukankan      html  css  js  c++  java
  • 关于FCKeditor的文件上传路径问题

    关于FCKeditor的文件上传路径问题   

        在.NET系统开发中,FCKeditor编辑器虽然有时加载时比较慢,但其功能完善,使用方便,还算是一个不错的编辑工具。在FCKEditor的文件 上传中,上传的路径可以有三种设置方式,第一种是获取用户的Application["FCKeditor:UserFilesPath"],第二种是 Session["FCKeditor:UserFilesPath"],第三种是System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"], 这也是常用的一种方式,即将路径写入到Web.config文件中,默认的路径是站点要目录下的“UserFiles”文件夹。在上传的过程中,如果将大 量的文件图片都集中在一个文件夹中,那么必然会造成这个文件夹过于庞大,不利管理。所以,对.NET用户来说,可以考虑将将日期文件保存在不同的文件夹 中,具体的做法如下:

      下载到FCKeditor.Net_2.2.zip文件,这个是编辑器.NET版本的源文件,用VS.2003打开,找到FileWorkBase.cs这个文件。这是一个抽象类,以下是它的私有成员:

    private string DEFAULT_USER_FILES_PATH = "/UserFiles/" ;
    private string sUserFilesPath ;
    private string sUserFilesDirectory ;

       第 一个是默认路径,第二个是用户上传的文件夹,默认就是第一个路径,第三个是文件夹路径,在这个设置中,其他可以暂时不管,设置 sUserFilesPath就可以。在protected string UserFilesPath { …… }这个属性中,可以在sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] 加上一个动态的日期,如DatePath。这样,路径便可以动态更新了。当然,在开始先对DatePath进行定义,如:private string DatePath = DateTime.Now.ToShortDateString();
       接下来就得对文件夹路径进行判断,自动新建文件夹。具体参考我个人给出的对UserFilesDirectory重写的例子吧。

    protected string UserFilesDirectory
    {
    get
    {
    if ( sUserFilesDirectory == null )
    {
    // Get the local (server) directory path translation.
    sUserFilesDirectory = Server.MapPath( this.UserFilesPath ) ;
    if(!System.IO.Directory.Exists(sUserFilesDirectory))
    {
    System.IO.Directory.CreateDirectory(sUserFilesDirectory);
    }

    }
    return sUserFilesDirectory ;
    }
    }
  • 相关阅读:
    日报9.4
    日报9.3
    低级错误整理
    树状数组求逆序对 笔记与思路整理
    st表、树状数组与线段树 笔记与思路整理
    Luogu P1098 字符串的展开
    Luogu P1816 忠诚
    jmeter cookie管理器 使用方法---新手学习记录1
    kali nessus 安装插件失败解决方法
    https tomcat 证书搭建
  • 原文地址:https://www.cnblogs.com/yangjunwl/p/930923.html
Copyright © 2011-2022 走看看