blueimp jquery文件上传完成回调无法在移动设备上运行

时间:2015-11-26 06:17:09

标签: jquery jquery-plugins blueimp

我正在使用blueimp jquery fileupload插件将图像上传到服务器它在所有浏览器的桌面上工作得非常好但是它不能在移动设备上运行 我不知道在移动设备上上传文件有什么我需要做的 我的代码是

$('#Add_image').fileupload({
        dataType: 'text',
        url: ImageUploadURL,
        dropZone: $('.image-upload '),
        singleFileUploads: false,
        limitMultiFileUploads: 8,
        autoUpload: true,
        add: function(e, data) {
            var valid = true;
            if($('#uploaded-images li').length>=8)
            {
                alert('You can not upload more than 8 Images');
                return false;
            }
            else
            {
                var re = /^.+\.((jpg)|(jpeg)|(png)|(gif)|(bmp))$/i;
                $.each(data.files, function (index, file) {
                    if (!re.test(file.name)) {
                        alert('Only jpg, png, gif and bmp image files are allowed');
                        valid = false;
                    }
                });
            }
            if (valid) {
                $('.progress-bar-container').show();
                data.url = ImageUploadURL+'&remove='+RemoveImage;
                data.submit();
            }
        },
        done: function (e, data) {
            data=$.parseJSON(data.result);
            if(data.Status)
            {
                if(data.RemovePrevious)
                {
                    $('#uploaded-images').empty();
                }
                $(data.Result).each(function(i,v){
                    $('#uploaded-images').append('<li data-imageid="'+v.ImageID+'"><img src="'+v.ImagePath+'?r='+Math.random()+'"/>'+
                        '<a class="remove-uploaded-image" data-imageid="'+v.ImageID+'" data-imagename="'+v.ImageName+'">Remove</a></li>');
                    if(data.RemovePrevious)
                    {
                        RemoveImage=v.ImageName;
                    }
                });
                if($('#uploaded-images li').length>=8)
                {
                    $('.image-file-upload-buttons').hide();
                }
                else
                {
                    $('.image-file-upload-buttons').show();
                }
            }
            else
            {
                alert('Oops');
            }
            return;
        }
    }).on('fileuploadprogressall', function (e, data) {
        var progress = parseInt(data.loaded / data.total * 100, 10);
                            
        setTimeout(function(e){
            $('.progress-value').text(progress+'%');
            $('.progress-bar').css('width',progress+'%');},100);

        if(progress==100)
        {
            setTimeout(function(e){
                $('.progress-bar').hide();
                setTimeout(function(e){
                    $('.progress-bar').css('width','0%');
                    $('.progress-value').text('0%');
                    $('.progress-bar').show();
                    $('.progress-bar-container').hide();
                },100);
            },1000);
        }
    })

请帮帮我

1 个答案:

答案 0 :(得分:1)

我知道现在已经很晚了,但这是一个解决方案。

转到jquery.fileupload-ui.js

查找autoupload并将其从false更改为true。