之前在时候用到webuploader ,起初是支持单实例,后来要求支持多实例.

webuploder API网址,如果不懂我说的可以去查看http://fex.baidu.com/webuploader/doc/index.html#WebUploader_Uploader_addButton

addButton

  • addButton( pick ) ⇒ Promise

添加文件选择按钮,如果一个按钮不够,需要调用此方法来添加。参数跟options.pick一致。

uploader.addButton({
id: '#btnContainer',
innerHTML: '选择文件'
});

下面是个人实例:

1.首先是页面

 

< = = =>
< =

  • =
  • = = = = =  =>
    >
    >
     = =></>
     =>
     = =>
     =>
    > = = > > = =
  • = =   = = = =   = =
  • = =
  • >
    >
    >
    >
     = =></>
    > == = =>>>
    >
    >
    >>
    >
     =
  • =>
     =>< =>>
    >
    >
     =>
     = =
  • = = = =
  • = =>
     = ==></>
  • ==>>
     = = =>
    >
    >
  • >
    >
    >
    >
    >
    >
    >>
    > = = = ="evalution({{=ord.odetId}},{{=ord.prod_id}})"="per_evaluate_btn upload_btn" = >
    >
    >
    >
    >
    </>
    </>

我们用的模板是doT.js来遍历集合  当然也有很多其他方式 比如说最近见到 用easyui框架 也可以显示列表

2. JavaScript

 

var;

  • evacom = 1;
  • fileNumLimit = 10000;
  • multiple = ;
  • imgtype = ;
  • punit = ;
  • (oldImgUrl != ) {
  • getImgByJson(oldImgUrl);
  • () {
  • FormValidation.init();
  • bigImg(id) {
  • deal(id) {
  • evacom = id;
  • + evacom);
  • }
  • amy_evaluate() {
  • $().css(, );
  • evaluate_off() {
  • ).css(, );
  • //
     showOrNo(ids) {
  • Imgmap =  Map();
  • + ids).raty({
  • width : 300
  • itid =  + ids;
  • (i, item) {
  • (ids != item.id) {
  • ,
  • multiple :
  • Map();
  • + evacom, Imgmap);
  • $list = $( + evacom);
  • (Imgmothermap == ) {
  • evacom = ids;
  • ,
  • multiple :
  • bloc =  + ids;
  • $(bloc).toggle();
  • }

3. Upload上传 Java关键代码

 

@RequestMapping, method = RequestMethod.POST)

  • getImgurlbyfile(HttpServletResponse response,
  • maxSize = ;
  • JSONObject();
  • String imgtype = request.getParameter();
  • );
  • ;
  • (Tools.isEmpty(imgtype)) {
  • , );
  • json.put(,
  • ));
  • }  {
  • (getBoolByType(myfile.getOriginalFilename().toLowerCase())) {
  • (myfile.getSize() <= maxSize) {
  • ( != myfile && !myfile.isEmpty()) {
  • (imgtype) {
  • :
  • filePath = Tools.uploadpicByShow(myfile, imgtype,
  • , , , , );
  • json.put(, );
  • , );
  • json.put(, filePath);
  • ;
  • :
  • );
  • , );
  • json.put(, );
  • , filePath);
  • ;
  • :
  • filePath = Tools.uploadpic(myfile, imgtype);
  • , );
  • json.put(, );
  • , filePath);
  • ;
  • {
  • , );
  • json.put(, BaseConfig.MESSAGE
  • ));
  • }
  • {
  • json.put(, );
  • ,
  • BaseConfig.MESSAGE.get());
  • {
  • , );
  • json.put(,
  • ));
  • }
  • {
  • (UnsupportedEncodingException e) {
  • e.printStackTrace();
  • }

webupload.js

 

$list = $();

  • count=0;
  • var Map();
  • thumbnailWidth = 100;
  • var
  • ,
  • fileVal : ,
  • ,
  • duplicate : ,
  • server : SHOPDOMAIN+ ,
  • ,
  • ,
  • ,
  • mimeTypes :
  • });
  • // 当有文件添加进来的时候
    'fileQueued'function
     $li = $(
  • + ), $img = $li
  • );
  • $btns = $(
  • , () {

  • $( + file.id).stop()
  • //      .animate({
    //          height : 30
    //      });

    , () {

  • + file.id).stop()
  • //          height : 0
    //      });

    , , () {

  • index = $().index(), deg;
  • (index) {
  • 0:
  • ;
  • 1:
  • $nextId=$(+file.id).next();
  • (undefined!=$nextId.attr()){
  • tempSrc=Imgmap.get($nextId.attr());
  • tempWu_File=$(+file.id);
  • Imgmap.put($nextId.attr(), Imgmap.get(file.id));
  • + file.id).stop().animate({
  • height : 0
  • ).html(Imgmap.toString());
  • ;
  • 2:
  • $prevId=$(+file.id).prev();
  • (undefined!=$prevId.attr()){
  • tempSrc=Imgmap.get($prevId.attr());
  • tempWu_File=$(+file.id);
  • ), Imgmap.get(file.id));
  • Imgmap.put(file.id, tempSrc);
  • + file.id).stop().animate({
  • ).html(Imgmap.toString());
  • }
  • ;
  • }
  • $list.append($li);
  • (error, src) {
  • (error) {
  • );
  • ;
  • , src);
  • }, thumbnailWidth, thumbnailHeight);
  • // 文件上传过程中创建进度条实时显示。
    'uploadProgress'(file, percentage) {
  • $li = $( + file.id), $percent = $li.find();
  • (!$percent.length) {
  • $percent = $(
    );
  • }
  • , percentage * 100 + );
  • // 文件上传成功,给item添加成功class, 用样式标记上传成功。
    'uploadSuccess'(file, response) {
  • ).css(,);
  • ).html(Imgmap.toString());
  • $( + file.id).addClass();
  • // 文件上传失败,显示上传出错。
    'uploadError'(file) {
  • $li = $( + file.id), $error = $li.find();
  • (!$error.length) {
  • $error = $(

    );

  • // 完成上传完了,成功或者失败,先删除进度条。
    'uploadComplete'(file) {
  • + file.id).find().remove();
  • });
  • // 完成上传完了,成功或者失败,先删除进度条。
    'error'(file) {
  • showMessage(file);
  • function
     tempImgPath = $().html();
  • (Imgmap.size()==0){
  • ).css(,);
  • }
  • ).html(Imgmap.toString());
  • $( + fileId).remove();
  • function

    ).css(,);

  • ( i=0; i<json.length; i++)
  • +json[i].id, json[i].uri);
  • $li = $(
    '_160''">'

    + ), $img = $li

  • );
  • $btns = $(
  • '">'

    , () {

  • tempId=$().attr();
  • $( + tempId).stop().animate({
  • , () {
  • tempId=$().attr();
  • + tempId).stop().animate({
  • height : 0
  • , , () {
  • tempId=$().parent().attr();
  • index = $().index(), deg;
  • (index) {
  • 0:
  • +tempId);
  • ;
  • 1:
  • $nextId=$(+tempId).next();
  • (undefined!=$nextId.attr()){
  • tempSrc=Imgmap.get($nextId.attr());
  • tempWu_File=$(+tempId);
  • Imgmap.put($nextId.attr(), Imgmap.get(+tempId));
  • +tempId, tempSrc);
  • $nextId.after(tempWu_File);
  • +tempId).stop().animate({
  • height : 0
  • ).html(Imgmap.toString());
  • ;
  • 2:
  • $prevId=$(+tempId).prev();
  • (undefined!=$prevId.attr()){
  • tempSrc=Imgmap.get($prevId.attr());
  • tempWu_File=$(+tempId);
  • ), Imgmap.get(+tempId));
  • Imgmap.put(+tempId, tempSrc);
  • +tempId).stop().animate({
  • ).html(Imgmap.toString());
  • }
  • ;
  • }
  • $list.append($li);
  • ).html(Imgmap.toString());
  • }

原理, 就是每次点击按钮的时候 对按钮进行绑定事件

 

addButton

  • addButton( pick ) ⇒ Promise
  • ,
  • });

每个按钮都有不同的id,所以说webuploader可以实例化多个按钮,这是重点,这样一个页面就支持多个评论了。

webuploader在同一个页面支持多个按钮实例的更多相关文章

  1. webuploader的一个页面多个上传按钮实例

    借鉴一位大佬的demo  附上他的github地址https://github.com/lishuqi 我把他的cxuploader.js改了不需要预览  直接上传图片后拿到回传地址给img标签显示图 ...

  2. [转] c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求

    在没有做题目中所述的内容的时候,感觉这应该是很简单的东西,但是当真正开始做的时候却发现,有很多问题现在在这里写出来,供和我一样水平不高的参考一下. 在写本文之前参照了一下文章 欢迎使用CSDN论坛阅读 ...

  3. 完美实现在同一个页面中使用不同样式的artDialog样式

    偶然发现artDialog.js这个插件,就被其优雅的设计及漂亮的效果深深吸引,在做例子时碰到了一些想当然它应该提供但却没有提供的功能,不过这都不影响我对它的喜爱,下面说一下遇到的问题吧! artDi ...

  4. iOS 实现单个页面支持横竖屏,其他页面只能竖屏

    最近在自己的项目里面 有需要做一个需求 : app中某一个页面支持横竖屏, 而其他页面只能竖屏. 1 2 实现方法如下: 1 首先需要Xcode中选中支持的屏幕方向  2 Appdelegate中 . ...

  5. 小程序webview跳转页面后没有返回按钮完美解决方案

    随着小程序越来越火爆,使一个产品如果只有公众号H5页面和APP显得不怎么完美,总感觉不搭上小程序这趟流量车,就会少了点什么,心里别扭地很.在此驱动下,我所在公司也决定赶紧上车. 但是,如果要按照小程序 ...

  6. 在同一个页面使用多个不同的jQuery版本,让它们并存而不冲突

    - jQuery自诞生以来,版本越来越多,而且jQuery官网的新版本还在不断的更新和发布中,现已经达到了1.6.4版本,但是我们在以前的项目中就已经使用了旧版本的jQuery,比如已经出现的:1.3 ...

  7. asp.net mvc jqgrid 同一个页面查询不同的表,jqgrid显示不同表的表头和数据并且分页

    基于我上一篇文章<a href="http://www.cnblogs.com/alasai/p/4765756.html">asp.net mvc excel导入&l ...

  8. 自己改写了一个图片局部放大的jquery插件页面里面的html代码少了,同一个页面可以调用多个

    自己改写了一个图片局部放大的jquery插件页面里面的html代码少了,同一个页面可以调用多个,兼容ie8以上浏览器,别忘了引用jquery,我用的jquery/1.11.0/其他版本没有测试,另外需 ...

  9. 多个测试类 只使用同一个浏览器,同一个driver对象, 或者同一个页面的对象

    如果是:多个测试类 只使用同一个浏览器,同一个driver对象, 或者同一个页面的对象,只需要:1. 创建一个基本的测试类(BaseTest),具有一个公共静态的driver属性, public st ...

随机推荐

  1. VC++ 0xC0000005: Access violation.

    public: COptionDlg(CWnd* pParent = NULL); // 标准构造函数 virtual ~COptionDlg(); TCONFIG m_tCfg; // 对话框数据 ...

  2. oracle进程

    http://blog.csdn.net/leshami/article/details/5529239 Oracle实例和Oracle数据库(Oracle体系结构) 几类进程:用户进程,服务进程,后 ...

  3. linux包之procps之pmap命令

    名称:       pmap - report memory map of a process(查看进程的内存映像信息)用法       pmap [ -x | -d ] [ -q ] pids... ...

  4. python数据库操作pymysql

    安装数据库: pip3 install pymysql 进行数据库的更新.插入.查询等操作: #!/usr/bin/python3.4 # -*- coding: utf-8 -*- #------- ...

  5. 安卓中Activity的onStart()和onResume()的区别是什么

    知道Activity的四种状态:Active/Runing 一个新 Activity 启动入栈后,它在屏幕最前端,处于栈的最顶端,此时它处于可见并可和用户交互的激活状态. Paused 当 Activ ...

  6. Java Dns Cache Manipulator

    通过代码直接设置Java的DNS(实际上设置的是DNS Cache),支持JDK 6+.  功能 设置/重置DNS(不会再去Lookup DNS) 可以设置单条 或是通过Properties文件批量设 ...

  7. C#.NET vs2010中使用IrisSkin4.dll轻松实现WinForm窗体换肤功能

    IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现WinForm窗体换肤 然而IrisSkin2.dll只能在.NET Faremwork 4.0以及之前的版本使用,所以要在V ...

  8. elasticsearch 跨网段组集群

    elasticsearch 是非常流行的全文搜索引擎,但网上的教程多是初次使用,并没有一些高级用法demo.这次遇到需要跨网段组网问题,自己摸索了文档很久,发现确实可行,于是着手做了个实验,最终实验成 ...

  9. hadoop(四): 本地 hbase 集群配置 Azure Blob Storage

    基于 HDP2.4安装(五):集群及组件安装 创建的hadoop集群,修改默认配置,将hbase 存储配置为 Azure Blob Storage 目录: 简述 配置 验证 FAQ 简述: hadoo ...

  10. html简介

    什么是 HTML? HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记语言 (ma ...