qq_32223965
qq_32223965
2017-11-15 06:37

使用WebUploader上传,文件一直是等待上传的状态

  • server
  • java
  • swf

贴一下代码
$(".addMesFactoryUploader").each(function(){
debugger;
uploaderCount ++ ;
var bussinessId = $(this).attr("bussinessId");
var picker = "#"+bussinessId+"picker";
var dnd = "#"+$(this).attr("id") + " ."+bussinessId+"btns";
var uploader = WebUploader.create({
// swf文件路径
swf: '${pageContext.request.contextPath}/platform/js/lib/webuploader/Uploader.swf',
// 文件接收服务端。
server: 'mesMat/saveAttaFile.do',
//选择文件的按钮。可选。
// 内部根据当前运行是创建,可能是input元素,也可能是flash.
pick: picker,
// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize: false,
dnd : dnd,
formData: {

business: "",
businessUuid:"",
propCode:"",
objectUuid:""
} ,
disableGlobalDnd: true
});

    uploader.on('fileQueued', function(file) {
        debugger;
        var lis = this.options.pick.substring(0,this.options.pick.length-6);
        var oId = file.id;
        $(lis+"thelist").append( '<div id="' + file.id + '" class="item">' +
            '<a class="info" title="'+file.name+'" >文件名称: ' + file.name + '  </a>'+'<span  class="state">等待上传...</span>' +
            '<button class="delFile" onclick="delFile(\''+lis+'\',\''+oId+'\');">Cancel</button>'+'</div>' );
    });

    uploader.on('uploadFinished', function(file) {
        uploaderCount--;
        if(uploaderCount == 0){
            submit();
        }
    });

    uploader.on( 'uploadSuccess', function( file , response ) {
        $( '#'+file.id ).find('span.state').text('上传成功');
        $( '#'+file.id ).find('button').hide();
        updateDocumentID(this.options.pick,response._raw);
    });
    uploaders[uploader.options.pick] = uploader;
});![图片说明](https://img-ask.csdn.net/upload/201711/15/1510727792_782059.png)
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答