PHP结合Ueditor并修改图片上传路径
使用ueditor编辑器,附件默认在ueditor/php/upload/, 但是大家的附件地址的默认路径可不是这个 ,需要修改ueditor,具体如何操作呢,下面我们就来详细讲解下
前言
在使用UEditor编辑器时,一般我们都是需要修改默认的图片上传路径的,下面是我整理好的修改位置和方法供大家参考。
操作
Ueditor PHP版本本身自带了一套上传程序,我们可以在此基础中,找到配置文件修改它。配置文件位置:
ueditor/php/config.json
内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
{ "imageActionName" : "uploadimage" , "imageFieldName" : "upfile" , "imageMaxSize" : 2048000, "imageAllowFiles" : [ ".png" , ".jpg" , ".jpeg" , ".gif" , ".bmp" ], "imageCompressEnable" : true , "imageCompressBorder" : 1600, "imageInsertAlign" : "none" , "imageUrlPrefix" : "" , "imagePathFormat" : "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}" , "scrawlActionName ": " uploadscrawl ", " scrawlFieldName ": " upfile ", " scrawlPathFormat ": " /ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} ", " scrawlMaxSize ": 2048000, " scrawlUrlPrefix ": " ", " scrawlInsertAlign ": " none ", " snapscreenActionName ": " uploadimage ", " snapscreenPathFormat ": " /ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} ", " snapscreenUrlPrefix ": " ", " snapscreenInsertAlign ": " none ", " catcherLocalDomain ": [" 127.0.0.1 ", " localhost ", " img.baidu.com "], " catcherActionName ": " catchimage ", " catcherFieldName ": " source ", " catcherPathFormat ": " /ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} ", " catcherUrlPrefix ": " ", " catcherMaxSize ": 2048000, " catcherAllowFiles ": [" .png ", " .jpg ", " .jpeg ", " .gif ", " .bmp "], " videoActionName ": " uploadvideo ", " videoFieldName ": " upfile ", " videoPathFormat ": " /ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6} ", " videoUrlPrefix ": " ", " videoMaxSize ": 102400000, " videoAllowFiles ": [ " .flv ", " .swf ", " .mkv ", " .avi ", " .rm ", " .rmvb ", " .mpeg ", " .mpg ", " .ogg ", " .ogv ", " .mov ", " .wmv ", " .mp4 ", " .webm ", " .mp3 ", " .wav ", " .mid "], " fileActionName ": " uploadfile ", " fileFieldName ": " upfile ", " filePathFormat ": " /ueditor/php/upload/file/{yyyy}{mm}{dd}/{time}{rand:6} ", " fileUrlPrefix ": " ", " fileMaxSize ": 51200000, " fileAllowFiles ": [ " .png ", " .jpg ", " .jpeg ", " .gif ", " .bmp ", " .flv ", " .swf ", " .mkv ", " .avi ", " .rm ", " .rmvb ", " .mpeg ", " .mpg ", " .ogg ", " .ogv ", " .mov ", " .wmv ", " .mp4 ", " .webm ", " .mp3 ", " .wav ", " .mid ", " .rar ", " .zip ", " .tar ", " .gz ", " .7z ", " .bz2 ", " .cab ", " .iso ", " .doc ", " .docx ", " .xls ", " .xlsx ", " .ppt ", " .pptx ", " .pdf ", " .txt ", " .md ", " .xml " ], " imageManagerActionName ": " listimage ", " imageManagerListPath ": " /ueditor/php/upload/image/ ", " imageManagerListSize ": 20, " imageManagerUrlPrefix ": " ", " imageManagerInsertAlign ": " none ", " imageManagerAllowFiles ": [" .png ", " .jpg ", " .jpeg ", " .gif ", " .bmp "], " fileManagerActionName ": " listfile ", " fileManagerListPath ": " /ueditor/php/upload/file/ ", " fileManagerUrlPrefix ": " ", " fileManagerListSize ": 20, " fileManagerAllowFiles ": [ " .png ", " .jpg ", " .jpeg ", " .gif ", " .bmp ", " .flv ", " .swf ", " .mkv ", " .avi ", " .rm ", " .rmvb ", " .mpeg ", " .mpg ", " .ogg ", " .ogv ", " .mov ", " .wmv ", " .mp4 ", " .webm ", " .mp3 ", " .wav ", " .mid ", " .rar ", " .zip ", " .tar ", " .gz ", " .7z ", " .bz2 ", " .cab ", " .iso ", " .doc ", " .docx ", " .xls ", " .xlsx ", " .ppt ", " .pptx ", " .pdf ", " .txt ", " .md ", " .xml" ] } |
从config.json内容中,我们不难看出(全部都有注释,看不出就见鬼了->_->),几乎所有的上传配置都是在这里。如果想修改上传路径,那么通过修改文件第 12 行就可以做到。
比如,这里我们修改 imagePathFormat :
"imagePathFormat": "/upload/ueditor/{yyyy}{mm}{dd}/{time}{rand:6}",
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了