哥们 你要做上传附件 那你的action请求为什么不使用Multipart请求呢?
不知道我说的对不对,你看看。

解决方案 »

  1.   


    <form   id= "form1 "   name= "form1 "   method= "post "   action= "Upload.action " ENCTYPE="multipart/form-data">
    这样
      

  2.   

    俺记得126邮箱是用透明度做滴,
    因为出于安全性考虑,点击动作必须由用户触发,
    而不能由脚本触发!// 这个动作被认为是不安全滴!
    //file.click(); L@_@K
    <!DOCTYPE   html   PUBLIC  "-//W3C//DTD   XHTML   1.0   Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html   xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312"   /> 
    <title> </title> <style   type="text/css"> 
    <!-- 
    .font1   { 
    font-family:  "宋体"; 
    font-size:   12px; 
    font-weight:   normal; 

    .files   { 
    width:   90px; 
    height:   30px; 
    overflow:   hidden; 
    display:   block; 
    border:   1px   solid   #BEBEBE; 
    background:   url(images/fu_btn.gif)   left   top   no-repeat; 
    text-decoration:   none; 

    #form1   .font1   .Loading   { 
    border:   1px   solid   #000099; 

    a:hover   { 
    color:   #FF3366; 

    a:link   { 
    color:   #0000CC; 

    a:visited   { 
    color:   #0000CC; 

    a:active   { 
    color:   #FF3366; 

    --> 
    </style> 
    <script language="javascript"> 
    function $(id)

    return document.getElementById(id); 

    function   CreateFile(){ 
    var   file=document.createElement("input"); 
    var   a=document.createElement("a"); 
    var   table=document.createElement("table"); 
    var   tbody=document.createElement("tbody"); 
    file.id="file"; 
    file.type="file"; 
    file.name="file"; 
    //file.style.visibility="hidden"; 
    a.href="javascript:void(0)"; 
    a.innerHTML="取消"; 
    a.onclick=function(){ 
    $("fileUp").removeChild(table); 
    $("files").removeChild(file); 

    $("files").appendChild(file);
    // 这个动作被认为是不安全滴!
    //file.click(); 
    var   url=file.value; 
    /*
    if(url==null||url=="")

    file.removeNode(); 
    return; 
    }
    */var   tr=new   Array(2); 
    var   td=new   Array(4); 
    var   tdid=new   Array(4); 
    tdid[0]="UpUrl"; 
    tdid[1]="Cancel"; 
    tdid[2]="Load"; 
    tdid[3]="Loadnum"; for(var   i=0;i <2;i++){ 
    tr[i]=document.createElement("tr"); 
    tbody.appendChild(tr[i]); 
    for(var   j=(i*2);j <(i+1)*2;j++){ 
    td[j]=document.createElement("td"); 
    td[j].id=tdid[j]; if(j%2==0){ 
    td[j].width="414"; 
    td[j].align="left"; 
    td[j].height="25"; 
    }else{ 
    td[j].width="70"; 
    td[j].align="center"; 
    td[j].height="15"; 
    } tr[i].appendChild(td[j]); 


    td[0].innerHTML=url; 
    td[1].appendChild(a); 
    td[2].innerHTML=" <div   class='Loading'> <img   src='images/loading.jpg'   title='下载进度'   width='100%'   height='5'   id='Loadimg'/> </div>"; 
    td[3].innerHTML="0%"; 
    table.appendChild(tbody); 
    table.border=0; 
    table.cellspacing=0; 
    table.cellpadding=0; 
    table.width=484; $("fileUp").appendChild(table); } 
    </script> 
    </head> <body> 
    <form id="form1" name="form1" method="post" action="Upload.action"> 
        <table width="623" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC"   class="font1"> 
            <tr> 
                <td   height="25"   colspan="2"   bgcolor="#F9F9F9"> 上传文件 </td> 
            </tr> 
            <tr> 
                <td   width="69"   align="right"   bgcolor="#FFFFFF"> 添加文件: </td> 
                <td   width="531"   height="25"   bgcolor="#FFFFFF"   id="files"> <input   id="addFile"   type="button"   class="files"   value="  "   /> </td> 
            </tr> 
            <tr> 
                <td   height="25"   colspan="2"   bgcolor="#FFFFFF"> <table   width="100%"   border="0"   align="center"   cellpadding="0"   cellspacing="1"   bgcolor="#CCCCCC"> 
                        <tr> 
                            <td   height="25"   bgcolor="#F9F9F9"> 文件路径 </td> 
                        </tr> 
                        <tr> 
                            <td   height="25"   bgcolor="#FFFFFF"   id="fileUp"> <!-- 
    <table   width="484"   border="0"   cellspacing="0"   cellpadding="0"> 
                                <tr> 
    <td   width="414"   height="25"   id="UpUrl"> C:\Documents   and   Settings\Administrator\桌面\16426828.jpg </td> 
                                    <td   width="70"   height="25"   align="center"   id="Cancel"> <a   href="javascript:void(0)"   id="lianjie"> 取消 </a> </td> 
                                </tr> 
                                <tr> 
                                    <td   height="15"   id="Load"> <div   class="Loading"> <img   src="images/loading.jpg"   title="下载进度"   width="100%"   height="5"   id="Loadimg"/> </div> </td> 
                                    <td   height="15"   align="center"   id="Loadnum"> 100% </td> 
                                </tr> 
                            </table> 
    --> </td> 
                        </tr> 
                </table> </td> 
            </tr> 
            <tr> 
                <td   height="12"   colspan="2"   bgcolor="#FFFFFF"> 温馨提示:可同时上传多个文件,只允许上传   <strong   id="idExt"> gif,jpg,rar,zip,iso,swf,mp3 </strong> 文件。 </td> 
            </tr> 
            <tr> 
                <td   height="12"   colspan="2"   align="center"   bgcolor="#FFFFFF"   id="running"> <input   type="submit"   id="UpLoads"   value="开始上传"   /> 
                <input   type="button"   id="exit"   value="全部取消"   /> </td> 
            </tr> 
        </table> 
        
    </form> </body> 
    <script>
    function $(id)

    return document.getElementById(id); 

    $("addFile").onclick=function(){ 
    CreateFile(); 

    $("UpLoads").onclick=function(){ 
    var div=document.createElement("frame"); 
    div.style.visibility ="hidden"; 
    div.id="a_hidden"; 
    div.name="a_hidden"; 
    $("files").appendChild(div); 
    // $("form1").action="http://www.baidu.com"; 
    $("form1").target="a_hidden"; 
     $("form1").enctype="multipart/form-data"; 
    // try{ 
    $("form1").submit(); 
    // }       
    // catch(e){ 
    // $("form1").submit(); 
    //} 
    $("UpLoads").disabled=true; 

    $("exit").onclick=function(){ 
    $("Loadimg").width=$("Loadimg").width*0.7; 

    </script> 
    </html> 
      

  3.   

    我在下面的javascript中有定义呀,可是结果还是一样的
      

  4.   

    3楼:可是我的提交动作是在最下面,和我自动打开input file文件域有关嘛,能解释一下吗
      

  5.   

    <form   id= "form1 "   name= "form1 "   method= "post "   action= "Upload.action " enctype="multipart/form-data"> 
    只要上传文件,基本上都要这个属性:enctype="multipart/form-data">
    注意了
    希望对你有帮助哦
    ^_*
      

  6.   

    楼上:
    我在这里有定义
    div.name="a_hidden"; 
    $("files").appendChild(div); 
    // $("form1").action="http://www.baidu.com"; 
    $("form1").target="a_hidden"; 
     $("form1").enctype="multipart/form-data";