javascript – 如何使用blueimp文件上传插件上传文件一次?

我正在使用 bluimp jQuery-File-Upload-plugin.选择一些文件上传它们没有问题,但是当我要上传一个文件而不刷新页面时,第一个文件将再次上传.我的问题是在上传文件后如何“取消设置”文件.这是我的源代码

使用Javascript:

$('#MappeFile').fileupload({
        dataType : 'json',autoUpload : false,maxnumberOfFiles : undefined,maxFileSize : 6000000,minFileSize : undefined,acceptFileTypes : /.+$/i,url : "/ajax/UploadFile.PHP",add : function(e,data) {
            $("#testUploadButton").on("click",function() {
                    $('#progress .bar').show();
                    if ($.browser.msie && parseInt($.browser.version,10) < 10) {
                        $('#progress .bar').css({
                            "background" : "url(images/progressbar.gif) no-repeat","width" : "100%"
                        })
                    } else {
                        $('#progress .bar').css({
                            'background-color' : "#2694E8",'width' : '0%'
                        });
                    }
                data.submit();
            })
        },change : function(e,data) {
            $.each(data.files,function(index,file) {
                console.info('Selected file: ' + file.name);
                filesCount++;
            });
        },drop: function(e,done : function(e,data) {
            $.each(data.result,file) {
                vOutput = "<tr>";
                vOutput += "<td>" + file + "</td>";
                vOutput += "<tr>";
                $("#MappeFileListe").append(vOutput);
                filesuploaded++;
                if (filesCount == filesuploaded) {
                    filesuploaded = 0;
                    filesCount=0;
                    $('#progress .bar').hide();
                }
            });
        },progressall : function(e,data) {
            var progress = parseInt(data.loaded / data.total * 100,10);
            $('#progress .bar').css('width',progress + '%');
        }
    });

HTML:

<div id="KundeMappe">
    <form id="MappeFile">
        <input type="file" id="MappeFileSelect" name="files[]" data-url="ajax/UploadFile.PHP" multiple/>
        <div id="progress">
            <div class="bar" style="width: 0%;"></div>
        </div>
        <input type="button" class="neuButton" value="upload" id="testUploadButton"/>
    </form>
    <table id="MappeFileListe"></table>
</div>

解决方法

我自己找到了答案 – 上传后,解除按钮的点击事件就足够了
add : function(e,'width' : '0%'
                        });
                    }
                data.submit();
                $("#testUploadButton").off("click")
            })
        },

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...