Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Blueimp-从队列中删除文件_Jquery_Blueimp - Fatal编程技术网

Jquery Blueimp-从队列中删除文件

Jquery Blueimp-从队列中删除文件,jquery,blueimp,Jquery,Blueimp,首先,我必须说我有关于stackoverflow的所有解决方案,但没有任何成功。我的问题很简单,我需要在单击开始上载按钮之前/之后从队列中删除文件,该按钮一次单击即可上载所有文件。。。。 我的代码: var indexProgressBar=1; $('#fileupload')。fileupload({ 自动上载:false, url:url, 数据类型:“json”, 顺序上传:正确, singleFileUploads:true, }).on('fileuploadadd',函数(e,数据

首先,我必须说我有关于stackoverflow的所有解决方案,但没有任何成功。我的问题很简单,我需要在单击开始上载按钮之前/之后从队列中删除文件,该按钮一次单击即可上载所有文件。。。。 我的代码:

var indexProgressBar=1;
$('#fileupload')。fileupload({
自动上载:false,
url:url,
数据类型:“json”,
顺序上传:正确,
singleFileUploads:true,
}).on('fileuploadadd',函数(e,数据){
$.each(data.files,函数(索引,文件){
var file=data.files[0];
file.uploadID='progress'+indexProgressBar;
file.uploadDivID='itemDiv'+indexProgressBar;
file.fileId='deleteButton'+indexProgressBar;
变量节点=$(''+file.name+'');
node.append(“
”); node.append(“”); node.appendTo($('#filesToUpload'); node.find(“img”)。单击(函数(){ node.remove(); }); }); indexProgressBar++; //手动上传 $(“#uploadBtn”)。在('click',函数(){ data.submit(); }); }).on('fileuploaddone',函数(e,数据){ //手动上传 $(“#uploadBtn”).off('click'); var uploadDivID=data.files[0]。uploadDivID;//返回'someidentification' 如果(data.result.status==“OK”){ $('#'+uploadDivID).fadeOut(1000,函数(){$(this.remove();}); } 否则{ $('#'+uploadDivID).append(“错误:+data.result.errorMsg+”); } }).on('fileuploadprogress',函数(e,数据){ var progress=parseInt(data.loaded/data.total*100,10); var progressID=data.files[0].uploadID;//返回'someidentification' $(“#”+progressID+”.progressbar').css( “宽度”, 进度+“%” ); //}).on('fileuploadprogressall',函数(e,数据){ //var progress=parseInt(data.loaded/data.total*100,10); //$('#progress.progress bar').css( //“宽度”, //进度+“%” // ); }).prop('disabled',!$.support.fileInput) .parent().addClass($.support.fileInput?未定义:“已禁用”);

问题是,这只是从视觉上删除文件,但我需要以某种方式从data.files中删除它,但我需要通过一个按钮上载所有文件。。。。嗯…谢谢你的帮助

我发现它是如何完美工作的。在阵列的帮助下,它工作得很好

            var a = [];

        var indexProgressBar = 0;

        $('#fileupload').fileupload({
            autoUpload: false,
            url: url,
            dataType: 'json',
            sequentialUploads: true,
            singleFileUploads: true,
        }).on('fileuploadadd', function (e, data) {

            $.each(data.files, function (index, file) {
                var file = data.files[0];
                file.uploadID = 'progress' + indexProgressBar;
                file.uploadDivID = 'itemDiv' + indexProgressBar;
                file.fileId = 'deleteButton' + indexProgressBar;

                var node = $('<div id=' + file.uploadDivID + ' style="margin-bottom:20px; font-size:11px;"><span class="progress-filename" style="width:286px; display:inline-block;">' + file.name + '</span ></div>');
                node.append('<img src="/_layouts/15/SkodaAuto.MarketingDatabank2.Project/Images/Icons/Delete-12.png" id=' + file.fileId + ' fileId=' + indexProgressBar + ' alt="delete" style="cursor:pointer;" /><br />');
                node.append('<div id="' + file.uploadID + '" class="progress" style="margin-bottom:0px; width:300px;" ><div class="progress-bar progress-bar-success"></div></div>');
                node.appendTo($('#filesToUpload'));

                node.find("img").click(function () {
                    a.push(file.fileId);
                    //data.files.splice($("#" + file.fileId).attr("fileId"), 1);

                    $(this).fadeOut(500, function () {
                        node.remove();
                    })

                });
            });

            indexProgressBar++;

            //upload Manualy
            $("#uploadBtn").on('click', function () {
                if ($.inArray(data.files[0].fileId, a) == -1) {
                    data.submit();
                }
            });
        }).on('fileuploadsend', function (e, data) {
            if ($.inArray(data.files[0].fileId, a) != -1) {
                return false;
            }
        }).on('fileuploaddone', function (e, data) {
            //upload Manualy
            $("#uploadBtn").off('click');

            var uploadDivID = data.files[0].uploadDivID; // returns 'someidentification'

            if (data.result.status == "OK") {
                $('#' + uploadDivID).fadeOut(1000, function () { $(this).remove(); });
            }
            else {
                $('#' + uploadDivID).append("<div style='color:red'>Error: " + data.result.errorMsg + "</div>");
            }

        }).on('fileuploadprogress', function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            var progressID = data.files[0].uploadID; // returns 'someidentification'

            $('#' + progressID + ' .progress-bar').css(
                'width',
                progress + '%'
            );

            }).on('fileuploadprogressall', function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
                $('#progress .progress-bar').css(
                    'width',
                    progress + '%'
                );
        }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');
下一个

接下来这个

//upload Manualy
                $("#uploadBtn").on('click', function () {
                    if ($.inArray(data.files[0].fileId, a) == -1) {
                        data.submit();
                    }
                });
还有这个

.on('fileuploadsend', function (e, data) {
                if ($.inArray(data.files[0].fileId, a) != -1) {
                    return false;
                }
            }).
就这样。。。多谢各位

 a.push(file.fileId);
//upload Manualy
                $("#uploadBtn").on('click', function () {
                    if ($.inArray(data.files[0].fileId, a) == -1) {
                        data.submit();
                    }
                });
.on('fileuploadsend', function (e, data) {
                if ($.inArray(data.files[0].fileId, a) != -1) {
                    return false;
                }
            }).