UEditor 编辑器常见问题解决

Posted xuey

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UEditor 编辑器常见问题解决相关的知识,希望对你有一定的参考价值。

ueditor单图上传图片显示上传错误/多图上传显示服务器错误,实际上图片已经传到服务器或者本地

1、这个问题是因为ueditor里面的Upload.class.php里面__construct()方法里面的iconv函数有问题

/*$this->stateMap[‘ERROR_TYPE_NOT_ALLOWED‘] = iconv(‘unicode‘, ‘utf-8‘, $this->stateMap[‘ERROR_TYPE_NOT_ALLOWED‘]);*/
$this->stateMap[‘ERROR_TYPE_NOT_ALLOWED‘] = mb_convert_encoding($this->stateMap[‘ERROR_TYPE_NOT_ALLOWED‘], ‘utf-8‘, ‘auto‘);

2、config.json 文件配置: imageUrlPrefix ,一般配置访问域名

 

请求后台http 配置错误,上传功能不能正常使用

1、ueditor.config.js

 //   var URL = window.UEDITOR_HOME_URL || getUEBasePath();
var URL =window.location.protocol+"//"+window.location.host; // 协议+域名,这里是80默认端口,如果是其他建议加上端口号

//为编辑器实例添加一个路径,这个不能被注释
UEDITOR_HOME_URL: ‘/ueditor/‘,// 静态文件路径

// 服务器统一请求接口路径
serverUrl: URL + "/plugin/EditorUpfile/requestUp",

2、config.json

*UrlPrefix=协议+域名+端口号 // 如果是80,可以不写
*PathFormat=> "/ueditor/upload/image/{yyyy}{mm}/{time}{rand:6}", /* 相对于域名上传保存路径,可以自定义保存路径和文件名格式 */

 

后端配置项没有正常加载,上传插件不能正常使用!

提示  errorHandler 未定义,在调用的前面添加

var errorHandler;
errorHandler = function(title) {
    var loader = me.document.getElementById(loadingId);
    loader && domUtils.remove(loader);
    me.fireEvent(‘showmessage‘, {
        ‘id‘: loadingId,
        ‘content‘: title,
        ‘type‘: ‘error‘,
        ‘timeout‘: 5000
    });
};

 

如果原型中定义了  showErrorLoader,可以直接调用 showErrorLoader。

 

可以测试一下 php 代码是否正确执行,在浏览器打开 ueditor/controller.php 对应的路径,看看是有配置值返回(json 格式)

技术图片
{"imageActionName":"uploadimage","imageFieldName":"upfile","imageMaxSize":10485760,"imageAllowFiles":[".jpeg",".jpg",".png",".gif"],"imageCompressEnable":true,"imageCompressBorder":1600,"imageInsertAlign":"none","imageUrlPrefix":"http://tp.com/","imagePathFormat":"/ueditor/upload/image/{yyyy}{mm}/{time}{rand:6}","scrawlActionName":"uploadscrawl","scrawlFieldName":"upfile","scrawlPathFormat":"/ueditor/upload/image/{yyyy}{mm}/{time}{rand:6}","scrawlMaxSize":2048000,"scrawlUrlPrefix":"","scrawlInsertAlign":"none","snapscreenActionName":"uploadimage","snapscreenPathFormat":"/ueditor/upload/image/{yyyy}{mm}/{time}{rand:6}","snapscreenUrlPrefix":"","snapscreenInsertAlign":"none","catcherLocalDomain":["127.0.0.1","localhost","img.baidu.com"],"catcherActionName":"catchimage","catcherFieldName":"source","catcherPathFormat":"/ueditor/upload/image/{yyyy}{mm}/{time}{rand:6}","catcherUrlPrefix":"","catcherMaxSize":2048000,"catcherAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"videoActionName":"uploadvideo","videoFieldName":"upfile","videoPathFormat":"/ueditor/upload/video/{yyyy}{mm}/{time}{rand:6}","videoUrlPrefix":"","videoMaxSize":104857600,"videoAllowFiles":[".avi",".mov",".wav",".mp4",".mp3"],"fileActionName":"uploadfile","fileFieldName":"upfile","filePathFormat":"/ueditor/upload/file/{yyyy}{mm}/{time}{rand:6}","fileUrlPrefix":"http://tp.com","fileMaxSize":52428800,"fileAllowFiles":[".txt",".doc",". docx",". xls",". xlsx",". ppt",".htm",".html",".zip",".rar",".gz",".bz2",".pdf"],"imageManagerActionName":"listimage","imageManagerListPath":"/ueditor/upload/image/","imageManagerListSize":20,"imageManagerUrlPrefix":"","imageManagerInsertAlign":"none","imageManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"fileManagerActionName":"listfile","fileManagerListPath":"/ueditor/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"]}
View Code

 

涂鸦提示糟糕,读取图片失败

需要在config.json 中添加 

"scrawlAllowFiles":[".png", ".jpg", ".jpeg", ".gif", ".bmp"]/* 图片格式 */

 

以上是关于UEditor 编辑器常见问题解决的主要内容,如果未能解决你的问题,请参考以下文章

百度UEditor编辑器源代码编辑模式用CSS会被转义,有解决方法吗

百度编辑器UEditor不能插入视频的解决方法

ueditor 编辑器在java项目中无法从本地上传图片,如何解决?

ueditor插入html代码保存后,再次编辑文章时html代码被过滤只显示文本内容!

解决ueditor编辑器图片在线管理图片无法显示

UEditor 编辑器常见问题解决