PHP结合Ueditor并修改图片上传路径

PHP结合Ueditor并修改图片上传路径

投稿:hebedich 字体:[ 增加 减小] 类型:转载 时间:2016-10-16
我要评论
使用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}”,

保存,上传,测试,查看源码:

PHP结合Ueditor并修改图片上传路径

此时可以看出,修改是成功的。

总结

上传配置这款,会因ueditor版本不同,而稍有不同,我刚开始在用新版本时也没有反应过来,寻根索源才找到了这里,大家在修改的时候也要注意下哦。

另外,如果需要修改其他上传,如视频等,也可以在此处文件修改,道理都是一样的。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/114401.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • 阿里-中间件团队博客「建议收藏」

    阿里-中间件团队博客「建议收藏」阿里中间件团队博客地址:http://jm.taobao.org/截至2019-03-15日已发布的博客列表:2017双11专题10 2018广东云栖大会1 ACM3 AHAS1 APM1 ARMS8 AlibabaCloudToolkit1 Aliware1 ApacheRocketMQ1 BCP1 CNCF1 Docker1 Dubbo10 Dubbo…

  • MFC中ASSERT_VALID fails with NULL pointer的个人解决办法[通俗易懂]

    MFC中ASSERT_VALID fails with NULL pointer的个人解决办法[通俗易懂]基于MFC在写一个利用GDAL和GDI+显示图像的系统,原有的Image::FromFile和Image::FromStream都用了一遍发现均会造成锁文件的情况,即使在程序用了delete的情况下,按道理FromStream应该不会锁但是我笨拙的编码依然是锁上了。。。索性换GDAL读图像然后用GDI+显示。在码代码中出现了如下的问题:VS2005调试输出显示:ASSERT_VALIDfai

  • 创建索引sql 语句「建议收藏」

    创建索引sql 语句「建议收藏」1、创建表的同时指定createtablet1( idintnotnull, namechar(30)notnull, uniqueindexUniqIdx(id))2、在已经存在的表创建索引使用ALTERTABLE语句创建索引1.执行语句altertablebookaddindexBkName(bookname(30))2…

  • linux查看cpu核数和内存大小_查看linux内核参数

    linux查看cpu核数和内存大小_查看linux内核参数在linux系统中,提供了proc系统显示系统的软硬件信息,可以使用命令cat/proc/cpuinfo来查看1.查看物理CPU个数cat/proc/cpuinfo|grep”physicalid”|sort|uniq|wc-l2.查看每个物理CPU中core的个数(即核数)cat/proc/cpuinfo|grep”cpucores”|uniq3查看逻辑CPU的个数cat/proc/cpuinfo|grep”processor”|wc-..

    2022年10月26日
  • emwin仪表控件_仪表开发工程师

    emwin仪表控件_仪表开发工程师本文导读i.MXRT1052具有增强型显示接口(eLCDIF),支持8/16/18/24位的数据总线模式。M1052核心板最高可支持1366×768的高清图像显示,芯片内置音频接口,搭载免费的emWin图形库可广泛应用多媒体设计。一、emWin介绍emWin是Segger公司针对嵌入式平台开发的稳定、高效的图形软件库,适合用于任何图形LCD的操作应用,并可输出高质量的无锯齿的文字和图形,通过调用…

    2022年10月14日
  • Delphi 2007体验!

    Delphi 2007体验!

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号