• 微软原版系统

  • 一键重装系统

  • 纯净系统

  • 在线技术客服

魔法猪系统重装大师 一键在线制作启动 U 盘 PE 系统 用一键重装的魔法拯救失去灵魂的系统
当前位置:首页 > 教程 > 电脑教程

.NET下FCKeditor动态设置不同用户使用不同的文件上传路径

时间:2015年04月02日 15:40:41    来源:魔法猪系统重装大师官网    人气:9641
首先看一下FCKeditor是如何获取用户的文件夹路径设置的,以及获取的顺序:

FCKeditor.net获取上传路径文件是:FileWorkerBase.cs,打开找到以下部分view plaincopy to clipboardprint?
protected string UserFilesPath
{
get
{
if ( sUserFilesPath == null )
{
// 第一回从application["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式
sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;

// 第二回从session["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;

// 第三回从web.config中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = System.Configuration.ConfigurationSettings.Appsettings["FCKeditor:UserFilesPath"] ;

// 第四回从DEFAULT_USER_FILES_PATH(这个变量在同文件中)中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
sUserFilesPath = DEFAULT_USER_FILES_PATH ;
// 第五回从网址参数ServerPath中读取
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = Request.QueryString["ServerPath"] ;
}

}
}

// Check that the user path ends with slash ("/")
if ( ! sUserFilesPath.EndsWith("/") )
sUserFilesPath += "/" ;
}
return sUserFilesPath ;
}
}

protected string UserFilesPath
{
get
{
if ( sUserFilesPath == null )
{
// 第一回从Application["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式
sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;

// 第二回从Session["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;

// 第三回从web.config中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;

// 第四回从DEFAULT_USER_FILES_PATH(这个变量在同文件中)中读取,如果没有尝试其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
sUserFilesPath = DEFAULT_USER_FILES_PATH ;

// 第五回从网址参数ServerPath中读取
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
{
sUserFilesPath = Request.QueryString["ServerPath"] ;
}

}
}

// Check that the user path ends with slash ("/")
if ( ! sUserFilesPath.EndsWith("/") )
sUserFilesPath += "/" ;
}
return sUserFilesPath ;
}
}

所以我们只要在Session中指定了路径就可以实现动态路径或多用户多路径了,下面看我的代码:

protected void Page_Load(object sender, EventArgs e)
{
Session["UserID"] = "12345679";
string URL = Session["UserID"].ToString();
Session["FCKeditor:UserFilesPath"]="~/factory/" + URL + "/UpLoadFile/";
}

在页面载入时设置用户的Session["UserID"],为不同用户指定一个ID,然后设置一下文件要上传了路径,动态的路径Session["FCKeditor:UserFilesPath"]是用Session["UserID"]结合我们的网站目录生成的一个路径。当然也可以直接在Session指定一个路径,然后赋值给Session["FCKeditor:UserFilesPath"]。

至此,我们简单的解决了fckeditor动态设置文件上传路径,解决多用户多路径的问题。
.NET,下,FCKeditor,动态,设置,不同,用户,使
栏目:电脑教程 阅读:1000 2023/12/27
Win7教程 更多>>
U盘教程 更多>>
Win10教程 更多>>
魔法猪学院 更多>>

Copyright © 2015-2023 魔法猪 魔法猪系统重装大师

本站发布的系统仅为个人学习测试使用,请在下载后24小时内删除,不得用于任何商业用途,否则后果自负,请支持购买微软正版软件。

在线客服 查看微信 返回顶部