uploadify插件BUG

Uploadify:

BUG1:文件上传后,点击“取消”或“取消所有上传”,然后上传同一个文件,提示“文件已存在”

修改方法:

找到源码中cancel取消方法:(添加代码)

 cancel: function (fileID, supressEvent) {

            var args = arguments;

            this.each(function () {

                // Create a reference to the jQuery DOM object

                var $this = $(this),

                swfuploadify = $this.data('uploadify'),

                settings = swfuploadify.settings,

                delay = -1;

                delete swfuploadify.queueData.files[fileID];

                if (args[0]) {

                    // Clear the queue

                    if (args[0] == '*') {

                        var queueItemCount = swfuploadify.queueData.queueLength;

                        $('#' + settings.queueID).find('.uploadify-queue-item').each(function () {

                            delay++;

                            if (args[1] === true) {

                                swfuploadify.cancelUpload($(this).attr('id'), false);

                            } else {

                                swfuploadify.cancelUpload($(this).attr('id'));

                            }

                            /* 添加代码 */

                            delete swfuploadify.queueData.files[$(this).attr('id')];

                            swfuploadify.queueData.queueLength = swfuploadify.queueData.queueLength - 1;

                            /* 添加结束 */

                            $(this).find('.data').removeClass('data').html(' - Cancelled');

                            $(this).find('.uploadify-progress-bar').remove();

                            $(this).delay(1000 + 100 * delay).fadeOut(500, function () {

                                $(this).remove();

                            });

                        });

                        swfuploadify.queueData.queueSize = 0;

                        swfuploadify.queueData.queueLength = 0;

                        // Trigger the onClearQueue event

                        if (settings.onClearQueue) settings.onClearQueue.call($this, queueItemCount);

                    } else {

                        for (var n = 0; n < args.length; n++) {

                            swfuploadify.cancelUpload(args[n]);

                            /* 添加代码 */

                            delete swfuploadify.queueData.files[args[n]];

                            swfuploadify.queueData.queueLength = swfuploadify.queueData.queueLength - 1;

                            /* 添加结束 */

                            $('#' + args[n]).find('.data').removeClass('data').html(' - Cancelled');

                            $('#' + args[n]).find('.uploadify-progress-bar').remove();

                            $('#' + args[n]).delay(1000 + 100 * n).fadeOut(500, function () {

                                $(this).remove();

                            });

                        }

                    }

                } else {

                    var item = $('#' + settings.queueID).find('.uploadify-queue-item').get(0);

                    $item = $(item);

                    swfuploadify.cancelUpload($item.attr('id'));

                    $item.find('.data').removeClass('data').html(' - Cancelled');

                    $item.find('.uploadify-progress-bar').remove();

                    $item.delay(1000).fadeOut(500, function () {

                        $(this).remove();

                    });

                }

            });

 

        }

 

BUG2:上传个文件提示“文件已存在”,点击“确定”,页面删除,但是再上传同一个文件是,会提示2次“文件已存在”(说明队列中文件根本没有删除只是页面显示删除了)

修改:找到对应的方法(根据提示信息搜索到对应的方法,添加代码)

onSelect: function (file) {

            // Load the swfupload settings

            var settings = this.settings;

            // Check if a file with the same name exists in the queue

            var queuedFile = {};

            for (var n in this.queueData.files) {

                queuedFile = this.queueData.files[n];

                if (queuedFile.uploaded != true && queuedFile.name == file.name) {

                    var replaceQueueItem = confirm('文件名为 "' + file.name + '" 文件已存在.\n你是否想在队列中替换现有的文件?');

                    if (!replaceQueueItem) {

                        this.cancelUpload(file.id);

                        this.queueData.filesCancelled++;

                        return false;

                    } else {

                    /* 添加代码 */

                        $('#' + queuedFile.id).remove();

                    /* 添加结束 */

                        this.cancelUpload(queuedFile.id);

                        this.queueData.filesReplaced++;

                    }

                }

            }

转载于:https://my.oschina.net/u/3234452/blog/1535368

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值