百度編輯器官方下載,並將文件放到項目根目錄下。javascript
由於vs2008 只到Framework 3.5,因此須要將4.0的東西去掉。java
1)下載.net framework 3.5版的 Newtonsoft.Json.dll 替換掉 /net/bin 中的。git
2)刪除 net 文件下 config.cs 裏的 using System.Dynamic,由於3.5版本沒有這個。github
3)查找替換,用 string.IsNullOrEmpty 替換 String.IsNullOrWhiteSpace。web
4)去掉 config.json 裏的解釋,否則上傳圖片功能用不了。(下面的能夠直接拿去用,裏面修改了圖片顯示的地址,"imageUrlPrefix": "" 原文是這樣:"imageUrlPrefix": "/ueditor/net/", /* 圖片訪問路徑前綴 */)json
{ "imageActionName": "uploadimage", "imageFieldName": "upfile", "imageMaxSize": 2048000, "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], "imageCompressEnable": true, "imageCompressBorder": 1600, "imageInsertAlign": "none", "imageUrlPrefix": "", "imagePathFormat": "/UeEditor/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", "scrawlActionName": "uploadscrawl", "scrawlFieldName": "upfile", "scrawlPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", "scrawlMaxSize": 2048000, "scrawlUrlPrefix": "/ueditor/net/", "scrawlInsertAlign": "none", "snapscreenActionName": "uploadimage", "snapscreenPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", "snapscreenUrlPrefix": "/ueditor/net/", "snapscreenInsertAlign": "none", "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"], "catcherActionName": "catchimage", "catcherFieldName": "source", "catcherPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", "catcherUrlPrefix": "/ueditor/net/", "catcherMaxSize": 2048000, "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], "videoActionName": "uploadvideo", "videoFieldName": "upfile", "videoPathFormat": "upload/video/{yyyy}{mm}{dd}/{time}{rand:6}", "videoUrlPrefix": "/ueditor/net/", "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": "upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", "fileUrlPrefix": "/ueditor/net/", "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": "upload/image", "imageManagerListSize": 20, "imageManagerUrlPrefix": "/ueditor/net/", "imageManagerInsertAlign": "none", "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], "fileManagerActionName": "listfile", "fileManagerListPath": "upload/file", "fileManagerUrlPrefix": "/ueditor/net/", "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" ] }
<script src="../../UeEditor/ueditor.config.js" type="text/javascript"></script> <script src="../../UeEditor/ueditor.all.min.js" type="text/javascript"></script> <script id="editor" type="text/plain" style="width: 1024px; height: 500px;"></script> <script type="text/javascript"> var ue = UE.getEditor('editor');//初始化後才能看到百度編輯器 function getData() { return UE.getEditor('editor').getContent();//獲取內容 } ue.ready(function() { //異步回調 UE.getEditor('editor').execCommand('insertHtml', "123456");//設置內容,用於修改功能 }); </script>
Ps:Js 的引用順序不能變,不然會報錯。下載的 demo 中有詳細用法。app
此時上傳圖片是很差使的,按F12,會看到報錯的信息,錯誤的緣由是由於沒有找到 net 文件夾中的 controller.ashx 這個文件。異步
controller.ashx 裏面寫了加載 config.json,加載到了,上傳圖片的功能也就好使了。編輯器
解決步驟:ide
一、修改 ueditor.config.js 文件,將, serverUrl: URL + "net/controller.ashx" 改爲 , serverUrl: "/UeEditor/controller.ashx" ,改爲相對路徑。(此處可不改,可是須要刪除 net 文件夾下的 web.config ,顯示圖片的路徑也會有些問題。)
二、準備工做中的第4條,已經處理了顯示圖片的路徑問題。(去掉註釋,清空路徑)
三、將 net 文件夾下的 config.json 與 controller.ashx 移動到 UeEditor 下。
效果:
Ps:關於圖片的保存路徑,能夠在 \net\App_Code 中 UploadHandler.cs 的 Process 方法中修改。