栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

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

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

前言

在使用UEditor编辑器时,一般我们都是需要修改默认的图片上传路径的,下面是我整理好的修改位置和方法供大家参考。

操作

Ueditor PHP版本本身自带了一套上传程序,我们可以在此基础中,找到配置文件修改它。配置文件位置:

ueditor/php/config.json

内容如下:


{
  
  "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}",

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

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

总结

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

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/42346.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号