您的位置:首页 > 其它

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

2007-10-19 21:04 337 查看
关于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 ;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: