2

我正在使用我在我的网站上实现的uploadifive(html5)jquery插件。在我添加文件后立即开始上传 - 在firefox中,但是当我在开始上传过程之前添加文件时,chrome会冻结2-4秒。我上传的文件大小约为 4-10 mb/文件。我可以做些什么来防止这种情况发生吗?任何帮助或建议将不胜感激。

代码:

$('#music_upload').uploadifive({
                                    'auto' :true,
                                    'queueID':'uploadqueue',
                                    'simUploadLimit': 1,
                                    'multi': true,
                                    'queueSizeLimit' : 50,
                                    'dnd': true,
                                    'width': 80,
                                    'height' : 23,
                                    'fileSizeLimit' : 20000,
                                    'buttonText' : 'Upload files',
                                    'formData'      : {'user' : $.cookie("username"),'key' : currentsession},
                                    'uploadScript' : '<?php echo site_url('home/upload_music_handler'); ?>',
                                    'removeCompleted' : false,
                                    'onCancel'     : function(file) {
                                       // remove song from database
                                       var username = $.cookie('username');
                                       //check if song extension
                                       if(checkFileExtension(file.name) == 'audio'){
                                            //remove file and remove from db
                                           $.post('<?php echo site_url('home/removesong'); ?>',
                                                    {ajax : 1, username : username, song_title : file.name},
                                                    function(data) {

                                                    },"json");

                                        }
                                        if(checkFileExtension(file.name) == 'image'){
                                            //else remove from album cover art
                                            $.post('<?php echo site_url('home/removealbumcover'); ?>',
                                                    {ajax : 1, username : username, song_title : file.name},
                                                    function(data) {

                                                    },"json");
                                            //remove from display


                                        }


                                       //remove file

                                       //remove li from song settings or album cover.
                                    },
                                    'onQueueComplete' : function(uploads) {

                                        $(".album-settings-section").show();

                                       //add sortable for queue-items
                                       $( "#uploadqueue").sortable({
                                            revert: true

                                        });
                                        $( ".uploadifive-queue-item" ).draggable({
                                            connectToSortable: "#uploadqueue",
                                            containment: "#uploadqueue",
                                            handle: ".song_drag",
                                            revert: "invalid"
                                        });

                                    },
                                    'onUploadComplete' : function(file, data) {

                                        $(file.queueItem).find('.songname').text(data);
                                        $( ".songname" ).disableSelection();
                                        $('.songname').bind('dblclick',
                                        function(e){
                                            e.preventDefault();
                                            $(this).attr('contentEditable',true);
                                        });
                                        //get and set the songname
                                        $(".public_or_private_album li a,.download_or_stream_album li a,.download_or_stream li a").click(function(e){
                                            e.preventDefault();
                                            $(this).parent().parent().find('.active').removeClass('active')
                                            $(this).parent().addClass('active');
                                        })
                                    }

                                }); //end of upload

上传音乐处理程序请求仅在我选择文件后 2-4 秒发送。

在此处输入图像描述

4

0 回答 0