使用ueditor编辑器,附件默认在ueditor/php/upload/,
但是大家的附件地址的默认路径可不是这个 ,需要修改ueditor,具体如何操作呢,下面我们就来详细讲解下
但是大家的附件地址的默认路径可不是这个 ,需要修改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" :
"imageAllowFiles" : ".png" , ".jpg" , ".jpeg" , ".gif" , ".bmp" ],
"imageCompressEnable" : true ,
"imageCompressBorder" :
"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 ":
" 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 ":
" catcherAllowFiles ": .png ", " .jpg ", .jpeg ", " .gif ", .bmp "],
" videoActionName ": uploadvideo ",
" videoFieldName ": upfile ",
" videoPathFormat ": /ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6} ",
" videoUrlPrefix ": ",
" videoMaxSize ":
" 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 ":
" 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 ":
" imageManagerUrlPrefix ": ",
" imageManagerInsertAlign ": none ",
" imageManagerAllowFiles ": .png ", " .jpg ", .jpeg ", " .gif ", .bmp "],
" fileManagerActionName ": listfile ",
" fileManagerListPath ": /ueditor/php/upload/file/ ",
" fileManagerUrlPrefix ": ",
" fileManagerListSize ":
" 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}",
"/upload/ueditor/{yyyy}{mm}{dd}/{time}{rand:6}",
保存,上传,测试,查看源码:
此时可以看出,修改是成功的。
总结
上传配置这款,会因ueditor版本不同,而稍有不同,我刚开始在用新版本时也没有反应过来,寻根索源才找到了这里,大家在修改的时候也要注意下哦。
另外,如果需要修改其他上传,如视频等,也可以在此处文件修改,道理都是一样的。