为什么此设置使文件始终处于上载状态,即使此文件已完全上载也是如此

时间:2011-12-04 17:09:00

标签: javascript swfupload

这是我的设置。我自定义了upload_success_handler,然后即使此文件已完全上传,文件也始终处于上传状态。我该怎么办?

        var settings = {
        flash_url : "/js/upload/swfupload.swf",
        upload_url: "/includes/imgupload.php",
        post_params: {"PHPSESSID" : "<?php echo session_id(); ?>","type":"post"},
        file_size_limit : "5 MB",
        file_types : "*.jpeg;*.jpg;*.png;*.gif",
        file_types_description : "JPEG Images;JPG Images;PNG Images;GIF Images;",
        file_upload_limit : 10,
        file_queue_limit : 10,
        custom_settings : {
            progressTarget : "fsUploadProgress",
            cancelButtonId : "btnCancel"
        },
        debug: false,
        //Button
        button_image_url: "images/TestImageNoText_65x29.png",
        button_width: "65",
        button_height: "29",
        button_placeholder_id: "btn-upload",
        button_text: '<span class="theFont">chose pictures</span>',
        button_text_style: ".theFont { font-size: 12; }",
        button_text_left_padding: 8,
        button_text_top_padding: 3,

        //The event handler functions are defined in handlers.js
        file_queued_handler : fileQueued,
        file_queue_error_handler : fileQueueError,
        file_dialog_complete_handler : fileDialogComplete,
        upload_start_handler : uploadStart,
        upload_progress_handler : uploadProgress,
        upload_error_handler : uploadError,
        //upload_success_handler : uploadSuccess,
        upload_success_handler : function(file,data){
            document.getElementById("holder").innerHTML +="<li><img class='thumb' src='/includes/thumbnail.php?id="+data+"' style='max-width:400px;'></img>";
            document.getElementById("holder").innerHTML +="<br><div>Pic"+item+"</div></li>";
            parent.addImg(item,data);
            item+=1;
            setStats(file,COMPLETE);
        },
        upload_complete_handler : uploadComplete,
        queue_complete_handler : queueComplete  // Queue plugin event
        };

2 个答案:

答案 0 :(得分:0)

setStats()需要1个参数,一个Stats对象,但是你传递了File-object。

此外:

    document.getElementById("holder").innerHTML +="<li><img class='thumb' src='/includes/thumbnail.php?id="+data+"' style='max-width:400px;'></img>";
    document.getElementById("holder").innerHTML +="<br><div>Pic"+item+"</div></li>";

没有结束标记。您还应该加入两个字符串,否则将取决于浏览器将呈现的结果:

document.getElementById("holder").innerHTML +=
  "<li><img class='thumb' src='/includes/thumbnail.php?id="+data+"' \
            style='max-width:400px;'/>\
            <br><div>Pic"+item+"</div></li>";

最后:什么是item和parent.addImg()?

答案 1 :(得分:0)

好吧,我在handler.js函数uploadsuccess()中找到了这些行:

    var progress=new FileProgress(file,this.customSettings.progressTarget);
progress.setComplete();
progress.setStatus("Complete.");

我将它们复制到我自己的处理函数中,它现在正在工作。