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
屬性