进度条失败,上传表单在php中

时间:2014-06-08 10:13:23

标签: javascript php jquery css

我的upload.php上有这样的代码:

调用javascript的语句如下所示:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script>
<script>

$(document).ready(function() { 
//

//show the progress bar only if a file field was clicked
    var show_bar = 0;
    $('input[type="file"]').click(function(){
        show_bar = 1;
    });

//show iframe on form submit
    $("ajax-contact-form").submit(function(){

        if (show_bar === 1) { 
            $('#upload_frame').show();
            function set () {
                $('#upload_frame').attr('src','upload_frame.php?up_id=<?php echo $up_id; ?>');
            }
            setTimeout(set);
        }
    });
//

});

</script>

这是表单代码语句:

<form id="ajax-contact-form" action=""  method="post" enctype="multipart/form-data" name="form1">

    <INPUT type="text" name="name" value="Material Name:" onBlur="if(this.value=='') this.value='Material Name:'" 
                            onFocus="if(this.value =='Material Name:' ) this.value=''">
    <div class="clear"></div><br>
    Choose a file to upload:<br />

<!--APC hidden field-->
    <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $up_id; ?>"/>
    <div class="clear"></div>
<!---->

    <input name="file" type="file" id="file" size="3000"/>
    <div class="clear"></div>
<!--Include the iframe-->
    <br />
    <iframe id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" > </iframe>

<!---->

    <INPUT class="submit" type="submit" name="submit" value="submit">
                  <div class="clear"></div>
  </form>

但是当我上传文件时,页面上没有显示进度条。虽然我输入了正确的地址,但它会出错。

我该如何解决问题?

...谢谢

1 个答案:

答案 0 :(得分:1)

这里有一个语法错误:

     setTimeout(set);

setTimeout()的语法是setTimeout(function,milliseconds,lang)