把ueditor编辑器放在项目根目录,目录名为ueditor
先配置editor_config.js
第14行imagePath:URL + "",
iframeUrlMap:{ 'anchor':'~/ueditor/dialogs/anchor/anchor.html', 'insertimage': '~/ueditor/dialogs/image/image.html', 'inserttable': '~/ueditor/dialogs/table/table.html', 'link': '~/ueditor/dialogs/link/link.html', 'spechars': '~/ueditor/dialogs/spechars/spechars.html', 'searchreplace': '~/ueditor/dialogs/searchreplace/searchreplace.html', 'map': '~/ueditor/dialogs/map/map.html', 'gmap': '~/ueditor/dialogs/gmap/gmap.html', 'insertvideo': '~/ueditor/dialogs/video/video.html', 'help': '~/ueditor/dialogs/help/help.html', 'highlightcode': '~/ueditor/dialogs/code/code.html', 'emotion': '~/ueditor/dialogs/emotion/emotion.html', 'wordimage': '~/ueditor/dialogs/wordimage/wordimage.html', 'insertframe': '~/ueditor/dialogs/insertframe/insertframe.html' },
'.anchorclass{background: url("' + URL + 'ueditor/themes/default/images/anchor.gif") ...
第299-230行
highlightJsUrl:URL + "ueditor/third-party/SyntaxHighlighter/shCore.js",
highlightCssUrl:URL + "ueditor/third-party/SyntaxHighlighter/shCoreDefault.css",
在ueditor/server/upload/net/文件夹下建立一般处理文件upload.ashx
修改ueditor/dialogs/image/image.html第304行url: '../../server/upload/net/upload.ashx',
Upload.ashx内容如下
<%@ WebHandler Language="C#" Class="upload" %> using System; using System.Web; using System.IO; public class upload : IHttpHandler { /// <summary> /// 配置 /// </summary> public struct Config { /// <summary>上传保存路径</summary> public string UploadPath; /// <summary>允许的单个文件大小,单位为KB</summary> public int PicSize; /// <summary>允许的图片格式</summary> public string PicType; } public void ProcessRequest(HttpContext context) { Config cfg = new Config(); cfg.UploadPath = "UploadFiles/" + DateTime.Now.ToString("yyyy/MM/dd/"); ; cfg.PicSize = 2048; cfg.PicType = ".jpg,.gif,.png,.bmp"; //文件上传状态,当成功时返回SUCCESS,其余值将直接返回对应字符窜并显示在图片预览框,同时可以在前端页面通过回调函数获取对应字符窜 string state = "SUCCESS"; string _upPath = context.Server.MapPath("~/" + cfg.UploadPath); string _returnPath = String.Empty;//返回路径 string _picTitle = context.Request.Form["pictitle"].ToString();//获取图片名称 HttpPostedFile _oFile = context.Request.Files["picdata"];//获取图片信息 string _fileExt = Path.GetExtension(_oFile.FileName).ToLower();//文件扩展名 if (cfg.PicSize * 1024 <= _oFile.ContentLength)//判断图片大小 state = "图片超过最大大小"; string[] picTypeArr = cfg.PicType.Split(',');//获取图片类型 if (Array.IndexOf(picTypeArr, _fileExt) < 0)//判断图片格式 state = "不允许上传该类型图片"; if (state == "SUCCESS") { Guid guid = Guid.NewGuid(); string filename = guid.ToString() + _fileExt;//文件名称 try { if (!Directory.Exists(_upPath)) Directory.CreateDirectory(_upPath); _oFile.SaveAs(_upPath + filename);//保存附件 _returnPath =cfg.UploadPath+ filename; } catch { state = "ERROR"; } } context.Response.ContentType = "text/Xml"; context.Response.AppendHeader("Cache-Control", "no-cache"); context.Response.Write("{'url':'" + _returnPath + "','title':'" + _picTitle + "','state':'" + state + "'}"); context.Response.End(); } public bool IsReusable { get { return false; } } }
测试成功,原创就是好呀~
@小白:欢迎常来
早就想把UEditor放到我的WordPress里面去的
他没有对应WordPress3.3.1的版本,很是郁闷,又懒得折腾。
于是就不用了。
@沉睡海洋:自己动手,丰衣足食
留下来看看
@losable:嗯嗯