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(這個(gè)變量在同文件中)中讀取,如果沒有嘗試其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
sUserFilesPath = DEFAULT_USER_FILES_PATH ;
// 第五回從網(wǎng)址參數(shù)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(這個(gè)變量在同文件中)中讀取,如果沒有嘗試其它方式
if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
sUserFilesPath = DEFAULT_USER_FILES_PATH ;
// 第五回從網(wǎng)址參數(shù)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中指定了路徑就可以實(shí)現(xiàn)動態(tài)路徑或多用戶多路徑了,下面看我的代碼:
protected void Page_Load(object sender, EventArgs e)
{
Session["UserID"] = "12345679";
string URL = Session["UserID"].ToString();
Session["FCKeditor:UserFilesPath"]="~/factory/" + URL + "/UpLoadFile/";
}
在頁面載入時(shí)設(shè)置用戶的Session["UserID"],為不同用戶指定一個(gè)ID,然后設(shè)置一下文件要上傳了路徑,動態(tài)的路徑Session["FCKeditor:UserFilesPath"]是用Session["UserID"]結(jié)合我們的網(wǎng)站目錄生成的一個(gè)路徑。當(dāng)然也可以直接在Session指定一個(gè)路徑,然后賦值給Session["FCKeditor:UserFilesPath"]。
至此,我們簡單的解決了fckeditor動態(tài)設(shè)置文件上傳路徑,解決多用戶多路徑的問題。