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"]}
涂鸦提示糟糕,读取图片失败
需要在config.json 中添加
"scrawlAllowFiles":[".png", ".jpg", ".jpeg", ".gif", ".bmp"]/* 图片格式 */
图片转存无法使用
ueditor.config.js 开启了 XSS 过滤(过滤、输入过滤、输出过滤都有相应的配置开关),任何不在 whitList
白名单上的标签及属性都会在转换时丢失。
第一种解决方法将一下三项设置为 false
// xss 过滤是否开启,inserthtml等操作 xssFilterRules: true, //input xss过滤 inputXssFilter: true, //output xss过滤 outputXssFilter: true,
第二种方法
- 插入锚点需要给
a
标签添加name
属性,给img
标签添加anchorname
属性 - 图片转存需要给
img
标签添加word_img
、style
属性