I’m using Jquery Plug-in FileUploader (BlueImp) to upload images. I want to allow the process of cancel one specific image from uploading.

I know that I can´t delete the image from the input (because is readonly), How can I do this ? 


$('#fileupload').fileupload({

                dataType: "json",
                url: "Handler.ashx?alp=0&bostamp=" + bostamp,
                limitConcurrentUploads: 1,
                sequentialUploads: true,
                progressInterval: 100,
                maxChunkSize: 17179869184,
                maxFileSize: 17179869184,


                add: function (e, data) {
                    var code = data.files[0].name;
                    var mlen = data.files[0].size;
                    var ftype = data.files[0].type;
                    var oktype = 'ok';
                    switch (ftype) {
                        case 'image/jpeg':
                            {
                                oktype = 'ok';
                                break;
                            }
                        case 'image/pjpeg':
                            {
                                oktype = 'ok';
                                break;
                            }
                        default:
                            {
                                oktype = 'nok';
                                break;
                            }
                    }
                    //limita tipo de ficheiro jpeg
                    if (oktype == 'nok') {
                        var opts = {
                            "closeButton": true,
                            "debug": false,
                            "positionClass": "toast-top-right",
                            "onclick": null,
                            "showDuration": "300",
                            "hideDuration": "1000",
                            "timeOut": "5000",
                            "extendedTimeOut": "1000",
                            "showEasing": "swing",
                            "hideEasing": "linear",
                            "showMethod": "fadeIn",
                            "hideMethod": "fadeOut"
                        };

                        toastr.error(code + ' ' + $('#lblerrformato').val(), "UPLOAD ERROR", opts);
                        //alert(code+' Unsupported File!');
                    } else {
                        //limita a 20MB por ficheiro 20971520

                        if (parseInt(mlen) > 52428800) {
                            var opts = {
                                "closeButton": true,
                                "debug": false,
                                "positionClass": "toast-top-right",
                                "onclick": null,
                                "showDuration": "300",
                                "hideDuration": "1000",
                                "timeOut": "5000",
                                "extendedTimeOut": "1000",
                                "showEasing": "swing",
                                "hideEasing": "linear",
                                "showMethod": "fadeIn",
                                "hideMethod": "fadeOut"
                            };

                            toastr.error(code + ' ' + $('#lblerrtamanho').val(), "UPLOAD ERROR", opts);
                            //alert(code+' ultrapassa o tamanho permitido.');
                        } else {
                            var maxse = $('#ctl00_hidseq').val();
                            //alert(maxse);
                            $('#filelistcontent').removeClass('hide');
                            $('#progress-holder').removeClass('hide');
                            data.context = $('<div />').text(data.files[0].name).appendTo('#filelistholder');
                            $('</div><div class="progress"><div class="progress-bar" style="width:0%"></div></div>').appendTo(data.context);

                            //novo codigo para apagar os ficheiros em espera quando necessario
                            $.each(data.files, function (index, file) {
                                $('</div> - <a href="#" class="deleteUpload"><span class="glyphicon glyphicon-trash" aria-hidden="true" style="font-size: 15px; margin-left:20px;"></span></a><hr>').appendTo(data.context);
                                console.log(index);
                                $('.deleteUpload').click(function () {
                                    $(this).parent().remove();
                                    $('#fileupload')
                                    if ($('#filelistholder').html() == "") {
                                        $('#filelistcontent').addClass('hide');
                                    }
                                });

                            });
                            $('#ctl00_btnUploadAll').click(function () {
                                data.submit();
                            });
                        }
                    }
                },
            });
amaia1921 Default Asked on October 27, 2018 in Programming.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.