1、修改 ueditor\net\config.json 文件
?
約 第78行:
/* 上傳文件配置 */"filePathFormat": "upload/{username}/file/{yyyy}{mm}{dd}/{time}{rand:6}",
約 第134行:
/* 列出指定目錄下的文件 */"fileManagerListPath": "upload/{username}/file",
?
修改說明:
1、給附件上傳地址添加 username 參數。(參數名可以自己定義,程序處理時一致即可。)
2、給在線文件列表路徑添加 username 參數。
?
默認參數說明:
"{time}", DateTime.Now.Ticks.ToString()//以0.1納秒為單位的時間戳
"{yyyy}", DateTime.Now.Year.ToString()//年
"{yy}", (DateTime.Now.Year % 100).ToString("D2")//年
"{mm}", DateTime.Now.Month.ToString("D2")//月
"{dd}", DateTime.Now.Day.ToString("D2")//日
"{hh}", DateTime.Now.Hour.ToString("D2")//時
"{ii}", DateTime.Now.Minute.ToString("D2")//分
"{ss}", DateTime.Now.Second.ToString("D2")//秒
"{filename}",originFileName //原始文件名(不含擴展名)
?
如果想保留原文件名,可以設置為(上傳時程序會覆蓋已有同名文件):
"filePathFormat": "upload/{username}/file/{yyyy}{mm}{dd}/{filename}",
?
2、修改 ueditor\net\App_Code\PathFormater.cs 文件
約 第46行:
pathFormat = pathFormat.Replace("{ss}", DateTime.Now.Second.ToString("D2")); /**新增用戶信息**/ pathFormat = pathFormat.Replace("{username}", (HttpContext.Current.Session?["UserID"]??"").ToString().Trim());
return pathFormat + extension;
?
修改說明: 處理username 參數 替換為用戶信息
?
3、修改 ueditor\net\controller.ashx 文件
約 第9行 :
public class UEditorHandler : IHttpHandler,System.Web.SessionState.IRequiresSessionState
?
約 第60行:
#Config.GetString("fileManagerListPath")--->PathFormatter.Format("",Config.GetString("fileManagerListPath"))
case "listfile": action = new ListFileManager(context, PathFormatter.Format("",Config.GetString("fileManagerListPath")), Config.GetStringList("fileManagerAllowFiles"));
break;
?
修改說明:
1、引入,System.Web.SessionState.IRequiresSessionState是為了取Session信息,否則一直為null (下同)
2、處理在線文件列表路徑 “fileManagerListPath”
?
4、修改 ueditor\net\App_Code\UploadHandler.cs 文件
約 第11行:
public class UploadHandler : Handler, System.Web.SessionState.IRequiresSessionState
?