• jquery-file-upload附件上传


    引入样式和js文件

        <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet"/>  
        <link rel="stylesheet" href="css/jquery.fileupload.css">  
        <link rel="stylesheet" href="css/jquery.fileupload-ui.css">   
        <script src="js/jquery.js"></script> 
        <script src="js/jquery.ui.widget.js"></script>  
        <script src="js/jquery.fileupload.js"></script>  

    html

    <body>
      <div class="row fileupload-buttonbar" style="padding-left:15px;">  
        <div class="thumbnail col-sm-6">  
          <img id="weixin_show" style="height:180px;margin-top:10px;margin-bottom:8px;"  src="__PUBLIC__/images/game/game_1.png" data-holder-rendered="true">  
          <div class="progress progress-striped active" role="progressbar" aria-valuemin="10" aria-valuemax="100" aria-valuenow="0">
            <div id="weixin_progress" class="progress-bar progress-bar-success" style="0%;"></div>
          </div>  
          <div class="caption" align="center">  
            <span id="weixin_upload" class="btn btn-primary fileinput-button">  
            <span>上传</span>  
            <input type="file" id="weixin_image" name="files" multiple>  
            </span>  
            <a id="weixin_cancle" href="javascript:void(0)" class="btn btn-warning" role="button" onclick="cancleUpload('weixin')" style="display:none">删除</a>
          </div>  
        </div>  
      </div> 
    </body>

    上传ajax:

        <script type="text/javascript">
          $(function() {  
              $("#weixin_image").fileupload({  
                      url: 'http://www.test007.com/ser/api/json/file/upload/batch',  
                      sequentialUploads: true  
                  }).bind('fileuploadprogress', function (e, data) {  //主要是进度条的修改
                      var progress = parseInt(data.loaded / data.total * 100, 10);  
                      $("#weixin_progress").css('width',progress + '%');  
                      $("#weixin_progress").html(progress + '%');  
                  }).bind('fileuploaddone', function (e, data) {  //上传结束后执行的操作
                      var imgurl = JSON.parse(data.result).data;
                      $("#weixin_show").attr("src", imgurl);  
                      $("#weixin_upload").css({display:"none"});  
                      $("#weixin_cancle").css({display:""});  
                  });  
                       
              });
    
        </script>
  • 相关阅读:
    对于数据的测试
    绕过前端,直接调用后端接口的可能性
    API接口自动化之3 同一个war包中多个接口做自动化测试
    API接口自动化之2 处理http请求的返回体,对返回体做校验
    API接口自动化之1 常见的http请求
    DB中字段为null,为空,为空字符串,为空格要怎么过滤取出有效值
    Linux 常用的压缩命令有 gzip 和 zip
    SQL 常用的命令
    JVM内存管理的机制
    Linux 常见命令
  • 原文地址:https://www.cnblogs.com/007sx/p/6160773.html
Copyright © 2020-2023  润新知