wangEditor 文本编辑器
参考:https://www.cnblogs.com/Scholars/p/8968838.html
前端代码:
<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 文本编辑器的更多相关文章
- 更加简洁易用——wangEditor富文本编辑器新版本发布
1. 前言 wangEditor富文本编辑器(www.wangEditor.com)从去年11月份发布,至今已经有将近10各月了.它就像一个襁褓中的小婴儿,在我的努力以及众多使用者的支持下不断摸索.成 ...
- 轻量级富文本编辑器wangEditor源码结构介绍
1. 引言 wangEditor——一款轻量级html富文本编辑器(开源软件) 网站:http://www.wangeditor.com/ demo演示:http://www.wangeditor.c ...
- 重构wangEditor(web富文本编辑器),欢迎指正!
提示:最新版wangEditor请参见:wangEditor.github.io 或者 https://github.com/wangfupeng1988/wangEditor 1. 前言 (下载源码 ...
- 富文本编辑器 - wangEditor 上传图片
效果: . 项目结构图: wangEditor-upload-img.html代码: <html> <head> <title>wangEditor-图片上传< ...
- 【前端】wangEditor(富文本编辑器) 简易使用示例
转载请说明作者或者注明出处,谢谢 说到前端常用的编辑器,自然也少不了富文本编辑器(RichText Editor) 笔者在此之前也看了一些相关的在线编辑器,其中包括了当百度搜索“富文本编辑器”字样时出 ...
- 是时候选择一款富文本编辑器了(wangEditor)
需要一款富文本编辑器,当然不能自己造轮子.本来想使用cnblog也在用的TinyMCE,名气大,功能全.但是发现TinyMCE从4.0开始,不再支持直接下载.所以还是决定选用wangEditor.遗憾 ...
- 基于jeesite的cms系统(五):wangEditor富文本编辑器
一.关于wangEditor: wangEditor —— 轻量级 web 富文本编辑器,配置方便,使用简单.支持 IE10+ 浏览器. 官网:www.wangEditor.com 文档:www.ka ...
- 轻量级富文本编辑器wangEditor
开发公司一个系统的时候需要一个富文本编辑器,找了几个,最后选择这个,蛮不错的. 百度搜索wangEditor,进入官网根据所介绍的使用进行开发就可以了,很不错的一个工具.
- wangEditor - 轻量级web富文本编辑器(可带图片上传)
业务需求: 通过后台编辑文章和图片,上传到前端界面,展示新闻消息模块.这个时候,需要一款简洁的编辑器,百度编辑器是最常用的一种,但是功能太过于复杂,而wangEditor - 轻量级web富文本编辑器 ...
随机推荐
- ASPOSE的示例下载地址
ftp://112.124.7.170/ASPOSE/Aspose.Words_16.3.0.zip http://blog.163.com/haolongqin@126/blog/static/10 ...
- Codeforces Round #421 (Div. 2) - B
题目链接:http://codeforces.com/contest/820/problem/B 题意:给定一个正n边形,然后让你选择3个不同的顶点,使得这3个顶点形成的角度尽可能的接近a. 思路:首 ...
- selenium下拉一个框内的滚动条
js='document.getElementsByClassName("route-tree")[0].scrollTop=10000'
- qt 视频播放
可以播出视频,待完善 player = new QMediaPlayer(this); playlist = new QMediaPlaylist(); playlist->addMedia(Q ...
- kafka参数设置
一.broker参数 broker.id:kafka集群的唯一标识. log.dirs:kafka存储消息日志的目录,多个用逗号隔开,需要保证指定的目录有充足的磁盘空间. zookeeper.conn ...
- 安装Git,Maven,配置ssh认证
安装git: yum -y install git 安装maven: wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries ...
- 转Serial,Parallel,CMS,G1四大GC收集器特点小结
转 https://blog.csdn.net/u013812939/article/details/48782343 1.Serial收集器 一个单线程的收集器,在进行垃圾收集时候,必须暂停其他所有 ...
- mitmproxy 使用mitmdump 过滤请求
mitmproxy 抓包工具,优点可以使用python进行二次开发,或者进行接口的mock 官网地址:https://www.mitmproxy.org/ 打算用这个最初的需求是,想对app做接口测试 ...
- 【leetcode】307. Range Sum Query - Mutable
题目如下: 解题思路:就三个字-线段树.这个题目是线段树用法最经典的场景. 代码如下: class NumArray(object): def __init__(self, nums): " ...
- 正则化的L1范数和L2范数
范数介绍:https://www.zhihu.com/question/20473040?utm_campaign=rss&utm_medium=rss&utm_source=rss& ...