Ueditor 1.4.3 单独调用上传图片,或文件功能
第一步, 引入文件
- <script src="ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
- <script src="ueditor/ueditor.all.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="../jquery.min.js" type="text/javascript" charset="utf-8"></script>
第二步 html元素
- <script type="text/plain" id="upload_ue"></script>
- 调用的页面:
- <input type="text" id="picture" name="cover" /><a href="javascript:void(0);" onclick="upImage();">上传图片</a>
- <input type="text" id="file" /><a href="javascript:void(0);" onclick="upFiles();">上传文件</a>
第三步 编写js代码
- <script type="text/javascript">
- var _editor;
- $(function() {
- //重新实例化一个编辑器,防止在上面的editor编辑器中显示上传的图片或者文件
- _editor = UE.getEditor('upload_ue');
- _editor.ready(function () {
- //设置编辑器不可用
- _editor.setDisabled();
- //隐藏编辑器,因为不会用到这个编辑器实例,所以要隐藏
- _editor.hide();
- //侦听图片上传
- _editor.addListener('beforeInsertImage', function (t, arg) {
- //将地址赋值给相应的input,只去第一张图片的路径
- $("#picture").attr("value", arg[0].src);
- //图片预览
- $("#preview").attr("src", arg[0].src);
- })
- //侦听文件上传,取上传文件列表中第一个上传的文件的路径
- _editor.addListener('afterUpfile', function (t, arg) {
- $("#file").attr("value", _editor.options.filePath + arg[0].url);
- })
- });
- });
- //弹出图片上传的对话框
- function upImage() {
- var myImage = _editor.getDialog("insertimage");
- myImage.open();
- }
- //弹出文件上传的对话框
- function upFiles() {
- var myFiles = _editor.getDialog("attachment");
- myFiles.open();
- }
- </script>
第四步 最重要的一步, 修改bug
打开image插件的image.js 108行
editor.execCommand('insertimage', list);代码之前加入
editor.fireEvent('beforeinsertimage', list);然后问题搞定
在ueditor文件夹中找到文件dialogs\attachment\attachment.html中找到代码
editor.execCommand("insertHTML",str);代码之前加入
editor.fireEvent('afterUpfile', filesList);然后问题搞定
Ueditor 1.4.3 单独调用上传图片,或文件功能的更多相关文章
- ueditor单独调用上传附件和图片的功能
javascript富文本编辑器使我们添加.编辑网站中的文章更加方便和容易.这些富文本编辑器提供了所见即所得(What You See Is What You Get - WYSIWYG)的功能,可以 ...
- 关于 百度 Ueditor (在chrome浏览器) 上传图片时 打开文件夹的延迟问题
在使用 ueditor 开发时, 作为一个web文本编辑器使用时. 当点击上传图片时, 文件夹要延迟好久才能打开. 解决: 针对多图片上传, 将/ueditor/dialogs/image/image ...
- 单独调用kindeditor的多图上传组件实现多图上传
本例是单独调用kindeditor多图上传的组件来进行多图上传,兼容性你懂得! 官方示例地址:http://kindeditor.net/ke4/examples/multi-image-dialog ...
- ajax 提交所有表单内容及上传图片(文件),以及单独上传某个图片(文件)
我以演示上传图片为例子: java代码如下(前端童鞋可以直接跳过看下面的html及js): package com.vatuu.web.action; import java.io.File; imp ...
- vue+Ueditor集成 [前后端分离项目][图片、文件上传][富文本编辑]
后端DEMO:https://github.com/coderliguoqing/UeditorSpringboot 前端DEMO:https://github.com/coderliguoqing/ ...
- sau交流学习社区--在element-ui中新建FormData对象组合上传图片和文件的文件对象,同时需要携带其他参数
今天有一个坑,同时要上传图片和文件,而且图片要展示缩略图,文件要展示列表. 我的思路是: 首先,只上传附件照片,这个直接看ele的官方例子就行,不仅仅上传附件照片,还同时上传其他参数. 然后,再做上传 ...
- Java调用第三方dll文件的使用方法 System.load()或System.loadLibrary()
Java调用第三方dll文件的使用方法 public class OtherAdapter { static { //System.loadLibrary("Connector") ...
- [VB.NET]调用系统的文件夹选择对话框
以下示例代码展示如何调用系统的文件夹选择对话框: Private Function SelectFolder(ByVal Describe As String, Optional ByVal Show ...
- delegate 集成在类中,还是单独写在.h文件中?
转:http://stackoverflow.com/questions/11382057/declaring-a-delegate-protocol There definitely are sub ...
随机推荐
- JS的setTimeout函数第一个参数问题
setTimeout的第一个参数只能放一个无参的函数,更像放了一个函数指针在那里,如果要放带参数的话,就要拿个匿名函数包裹一下
- oc-14-对象方法调用类方法
Person.h #import <Foundation/Foundation.h> @interface Person : NSObject { @public int _age; fl ...
- ubuntu thrift 0.9.3编译安装
Table of Contents 1. 下载thrift源代码 2. 编译并安装 3. 运行测试程序 4. 安装 1 下载thrift源代码 git clone https://git-wip-us ...
- 基于 SquashFS 构建 Linux 可读写文件系统
转载:http://www.oschina.net/question/129540_116839 在当前的嵌入式操作系统开发中,Linux 操作系统通常被压缩成 Image 后存放在 Flash 设备 ...
- 第一个c++程序 helloworld
// helloworld.cpp : 定义控制台应用程序的入口点.// #include "stdafx.h"#include "iostream" int ...
- LeetCode30 Substring with Concatenation of All Words
题目: You are given a string, s, and a list of words, words, that are all of the same length. Find all ...
- 去掉或者修改 input、select 等表单的【默认样式 】
隐藏input等表单的默认样式的背景: textarea,select,input{-webkit-appearance: none; -moz-appearance: none; -o-appear ...
- 快递鸟API接口调用代码示例(免费不限量)
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...
- [SQLServer]学习总结笔记(基本涵盖Sql的所有操作)
--################################################################################### /* 缩写: DDL(Dat ...
- 在ios开发中nil和NUll和Nilde区别————和如何判断连个对象的关系和UISlider不能拖动的问题
nil表示一个对象指针为空,针对对象 >示例代码: NSString *someString = nil; NSURL *someURL = nil; id someObject = nil; ...