Ueditor 改造, 为每个用户单独创建上传附件目录,用户只能查看自己上传的附件文件
生活随笔
收集整理的這篇文章主要介紹了
Ueditor 改造, 为每个用户单独创建上传附件目录,用户只能查看自己上传的附件文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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?
總結
以上是生活随笔為你收集整理的Ueditor 改造, 为每个用户单独创建上传附件目录,用户只能查看自己上传的附件文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 企业数字化转型的加速引擎 — 2019年
- 下一篇: Python 实现 csv文件转换成js