uploadify插件BUG
uploadify插件BUG
流云飘雪dyg 发表于1个月前
uploadify插件BUG
  • 发表于 1个月前
  • 阅读 1
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 十分钟定制你的第一个小程序>>>   

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++;

                    }

                }

            }

共有 人打赏支持
粉丝 4
博文 2
码字总数 597
×
流云飘雪dyg
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: