• 关于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 ;
    }
    }
  • 相关阅读:
    Android 聊天表情输入、表情翻页带效果、下拉刷新聊天记录
    android启动界面
    ubuntu 关于sublime text3的一些应用
    [LeetCode]Valid Sudoku解题记录
    在 Mac OS X 10.10 安装 pyenv 的一个小坑
    java调用百度地图API依据地理位置中文获取经纬度
    debug openStack
    error recoder,error debug for openStack kilo
    SDN,NFV
    openStack kilo 手动Manual部署随笔记录
  • 原文地址:https://www.cnblogs.com/yangjunwl/p/930923.html
Copyright © 2020-2023  润新知