uploadify插件BUG

Uploadify:html

BUG1:文件上傳後,點擊「取消」或「取消全部上傳」,而後上傳同一個文件,提示「文件已存在」this

修改方法:htm

找到源碼中cancel取消方法:(添加代碼)隊列

 cancel: function (fileID, supressEvent) {rem

            var args = arguments;get

            this.each(function () {源碼

                // Create a reference to the jQuery DOM object文件上傳

                var $this = $(this),it

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

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

                    }

                }

            }

相關文章
相關標籤/搜索