zoukankan      html  css  js  c++  java
  • ace input file 上传

    1、定义一个  弹出dialog   

    <div class="form-group">
    <form id="addForm" action="" enctype="multipart/form-data">
    <label class="col-sm-2 control-label text-right"><b class="red">*</b>附件:</label>

    <div class="col-xs-10">
    <!-- #section:custom/file-input -->
    <div class="col-sm-6">
    <%--注意: form 必须设置为 enctype="multipart/form-data" 否则无法识别问文件上传;不使用该控件的时候不设置也可以--%>
    <input type="file" id="id-input-file" name="file"/>
    </div>
    <div class=" col-sm-6">
    <a id="downLoadTemplateId" class="btn btn-info btn-minier btn-success" style="line-height: 23px" href="">
    <i class="ace-icon fa fa-download"></i>模版下载
    </a>
    </div>
    </div>
    <div class="form-group row" id="fileDiv">
    <input name="fileName" id="file-name" type="hidden" >
    <input name="fileUrl" id="file-url" type="hidden">
    <input name="fileSize" id="file-size" type="hidden">
    </div>
    </form>
    </div>

    2、js 进行初始化

      $('#id-input-file').ace_file_input({
    no_file:'没有选择文件',
    btn_choose:'选择',
    btn_change:'更改',
    icon_remove:null,
    droppable:false,
    thumbnail:false,//| true | large
    // whitelist:'gif|png|jpg|jpeg', //黑白名单并没有起作用
    allowExt: ['xls','xlsx'], //该属性只是对文件后缀的控制
    before_change: function(files, dropped){
    //选择文件 展示之前的事件
    //return true 保留当前文件; return false 不保留文件;return -1 重置文件框
    //需要同步等待返回结果
    uploadjs.upload('addForm',setFileUrl,'id-input-file',"");
    return true;
    }
    }).on('file.error.ace', function(event, info) {
    nsDialog.jAlert("请上传excel格式文件","提示");
    });
  • 相关阅读:
    我在博客园的第一篇博客
    第5次作业--对象的创建与使用
    20194622 JAVA--static、this、包总结--求阶乘
    蔡奇宏软件工程第二次作业--四则运算
    蔡奇宏软件工程第一次作业
    JAVA NIO工作原理及代码示例
    Java实现八大排序算法
    union和union all的区别
    .NET MVC model数据验证
    解决VS 2015模版中找不到ADO.NET Entity Data Model的方法
  • 原文地址:https://www.cnblogs.com/cbliu/p/5881716.html
Copyright © 2011-2022 走看看