日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Ueditor 改造, 为每个用户单独创建上传附件目录,用户只能查看自己上传的附件文件

發布時間:2023/12/4 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 改造, 为每个用户单独创建上传附件目录,用户只能查看自己上传的附件文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。