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