参考:https://www.cnblogs.com/Scholars/p/8968838.html

下载:http://www.wangeditor.com/

前端代码:

<script type="text/javascript">
//下面这两行脚本就是弹出文本框
var E = window.wangEditor
var editor = new E('#editor')
// 上传图片(举例)
editor.customConfig.uploadImgServer = '/upload.ashx' //将网络图片隐藏掉
editor.customConfig.showLinkImg = false // 将 timeout 时间改为 3s
editor.customConfig.uploadImgTimeout = * ; document.getElementById('btn1').addEventListener('click', function () {
// 读取 html
alert(editor.txt.html())
}, false) editor.create();
</script> <body>
<form id="newspost" method="post" action="newspost" enctype="multipart/form-data"> <input type="hidden" id="content" name="content"/>
<div style="padding: 5px 0; color: #ccc"></div>
<div id="editor"></div>
<br/> </form>
<button id="btn1">获取html</button>
</body>

后端代码(一般处理程序):

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web; namespace WebApplication1
{
/// <summary>
/// upload 的摘要说明
/// </summary>
public class upload : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8"; var files = context.Request.Files;
if (files.Count <= )
{
return;
} HttpPostedFile file = files[]; if (file == null)
{
context.Response.Write("error|file is null");
return;
}
else
{
string Url = "http://192.168.0.20:8099/IMG/"; string path = context.Server.MapPath("/Upader/Img/"); //存储图片的文件夹
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
} string originalFileName = file.FileName;
string fileExtension = originalFileName.Substring(originalFileName.LastIndexOf('.'), originalFileName.Length - originalFileName.LastIndexOf('.'));
string currentFileName = (new Random()).Next() + fileExtension; //文件名中不要带中文,否则会出错
//生成文件路径
string imagePath = path + currentFileName; //保存文件
file.SaveAs(imagePath); //获取图片url地址
string imgUrl = "./Upader/Img/" + currentFileName; string Json = "{\"data\": [\"../../" + imgUrl.Replace(@"\", @"/") + "\"],\"errno\":\"0\"}"; //返回图片url地址
context.Response.Write(Json);
return;
}
} public bool IsReusable
{
get
{
return false;
}
} }
} 一般处理程序代码

wangEditor 文本编辑器的更多相关文章

  1. 更加简洁易用——wangEditor富文本编辑器新版本发布

    1. 前言 wangEditor富文本编辑器(www.wangEditor.com)从去年11月份发布,至今已经有将近10各月了.它就像一个襁褓中的小婴儿,在我的努力以及众多使用者的支持下不断摸索.成 ...

  2. 轻量级富文本编辑器wangEditor源码结构介绍

    1. 引言 wangEditor——一款轻量级html富文本编辑器(开源软件) 网站:http://www.wangeditor.com/ demo演示:http://www.wangeditor.c ...

  3. 重构wangEditor(web富文本编辑器),欢迎指正!

    提示:最新版wangEditor请参见:wangEditor.github.io 或者 https://github.com/wangfupeng1988/wangEditor 1. 前言 (下载源码 ...

  4. 富文本编辑器 - wangEditor 上传图片

    效果: . 项目结构图: wangEditor-upload-img.html代码: <html> <head> <title>wangEditor-图片上传< ...

  5. 【前端】wangEditor(富文本编辑器) 简易使用示例

    转载请说明作者或者注明出处,谢谢 说到前端常用的编辑器,自然也少不了富文本编辑器(RichText Editor) 笔者在此之前也看了一些相关的在线编辑器,其中包括了当百度搜索“富文本编辑器”字样时出 ...

  6. 是时候选择一款富文本编辑器了(wangEditor)

    需要一款富文本编辑器,当然不能自己造轮子.本来想使用cnblog也在用的TinyMCE,名气大,功能全.但是发现TinyMCE从4.0开始,不再支持直接下载.所以还是决定选用wangEditor.遗憾 ...

  7. 基于jeesite的cms系统(五):wangEditor富文本编辑器

    一.关于wangEditor: wangEditor —— 轻量级 web 富文本编辑器,配置方便,使用简单.支持 IE10+ 浏览器. 官网:www.wangEditor.com 文档:www.ka ...

  8. 轻量级富文本编辑器wangEditor

    开发公司一个系统的时候需要一个富文本编辑器,找了几个,最后选择这个,蛮不错的. 百度搜索wangEditor,进入官网根据所介绍的使用进行开发就可以了,很不错的一个工具.

  9. wangEditor - 轻量级web富文本编辑器(可带图片上传)

    业务需求: 通过后台编辑文章和图片,上传到前端界面,展示新闻消息模块.这个时候,需要一款简洁的编辑器,百度编辑器是最常用的一种,但是功能太过于复杂,而wangEditor - 轻量级web富文本编辑器 ...

随机推荐

  1. neo4j传参

    py2neo_graph= py2neo.Graph("http://****", user="****", password="*****" ...

  2. Flutter-ListTile

    ListTile 通常用于在 Flutter 中填充 ListView.在这篇文章中,我将用可视化的例子来说明所有的参数. title title 参数可以接受任何小部件,但通常是文本小部件 List ...

  3. hive之wordcount

    1.创建一张表,记录文件数据,使用换行符作为分隔符 create table file_data(content string) row format delimited fields termina ...

  4. java实现js端的escape和unescape

    1.今天遇到这么个问题,需要把一些特殊字符传递到后台进行处理,例如Aa111111!@#,结果到了后台出现了个别字符中文符号了.这个时候需要转码.常见的就是js端的escape和unescape这种函 ...

  5. H700关闭Direct PD Mapping

    Attached Enclosure doesn't support in controller's Direct mapping modePlease contact your system sup ...

  6. 20180715-Java String类

    public class StringDemo{ public static void main(String args[]){ char[] helloArray = {'h','e','l','l ...

  7. vue中操作Dom节点的方法

    1.vue中ref操作dom节点 <template> <div id="app"> <div </div> <button @cl ...

  8. java并发编程如何预防死锁

    在java并发编程领域已经有技术大咖总结出了发生死锁的条件,只有四个条件都发生时才会出现死锁: 1.互斥,共享资源X和Y只能被一个线程占用 2.占有且等待,线程T1已经取得共享资源X,在等待共享资源Y ...

  9. python3爬虫开发与实战预览版

    https://germey.gitbooks.io/python3webspider/content/1.2.3-ChromeDriver%E7%9A%84%E5%AE%89%E8%A3%85.ht ...

  10. ProxyImpl 类

    package com.test.mvp.mvpdemo.mvp.v7.proxy; import com.test.mvp.mvpdemo.mvp.v7.basemvp.BasePresenter; ...