第二步,編寫后臺代碼。 **注意,以下僅是算法描述,你可以使用asp.net、jsp、php等任何web框架,來實現該程序**。
>請注意算法描述中**標注『重要』的部分**。
```C#
//重要:類型必須是 "text/html"
response.ContentType = "text/html";
response.Charset = "utf-8";
//獲取第一步中得到的 wangEditor_uploadImg_assist.html 頁面的url地址
string assitUrl = "http://localhost:8080/wangEditor_uploadImg_assist.html";
//獲取文件對象
File file = request.Files[0];
//重要:你可以可以通過 File file = request.Files["wangEditor_uploadImg"]; 來獲取文件對象
//重要:用該方法獲取時,key必須寫“wangEditor_uploadImg”,否則出錯
//驗證、保存文件,省略此處代碼
if(success) {
//如果保存成功
//重要:獲取圖片的url地址
string imgUrl = ...省略此處代碼...;
//重要:assitUrl 即 wangEditor_uploadImg_assist.html 的url地址
//重要:別忘了“ok|”
string iframeSrc = assitUrl + "#" + "ok|" + imgUrl;
//拼接最終結果
string result = "<iframe src=\"" + iframeSrc + "\"></iframe>";
//返回
response.Write(result);
response.End();
return;
} else {
//如果失敗
//重要:此處的“上傳失敗”可隨意填寫
string iframeSrc = assitUrl + "#" + "上傳失敗";
string result = "<iframe src=\"" + iframeSrc + "\"></iframe>";
response.Write(result);
response.End();
return;
}
```
- 關于wangEditor
- 基本應用
- 開始使用
- 下載wangEditor
- 創建頁面
- 生成編輯器
- 與font-awesome的沖突
- 設置高度
- 設置絕對高度
- 默認高度和最大高度
- 初始化內容
- html方式
- javascript方式
- 獲取內容
- 追加內容
- 基本配置
- 自定義配置菜單
- 配置onchange監聽事件
- 自定義配置表情圖標
- 簡單表情
- 多組表情
- 配置代碼高亮
- 下載highlight
- 使用highlight
- 與wangEditor集成
- 不過濾javascript代碼
- 圖片上傳
- 非跨域
- 使用plupload做一個上傳圖片的頁面
- 在頁面加入wangEditor
- 將兩者結合
- 后臺代碼示例
- C#
- java
- php
- nodejs
- 征集
- 跨域
- 下載 wangEditor_uploadImg_assist.html
- 編寫后臺代碼
- 配置url地址
- 后臺代碼示例
- C#
- java
- python
- nodejs
- 征集
- 粘貼截圖
- 其他
- 多語言支持
- 默認中文
- 使用英文
- 使用其他語言
- 單頁多個編輯器
- 使用requirejs
- 使用seajs
- 增加 placeholder 功能
- 定制開發