0

我正在尝试提交一个动态生成的表单。表单提交后,我从Form除了一个元素(文件元素)之外获取所有值。甚至我的表单 enctype 也是multipart/form-data.

我检查过HTTPfox它显示在下面

Content-Disposition: form-data; name="upfile1"; filename=""
Content-Type: application/octet-stream

我不明白这里发生了什么。

       var str_new='<form id="uploader'+count+'" action="testkal.php" name="frmattach_kal" class="uploader" method="post" enctype="multipart/form-data" target="upload_target'+count+'"><div id="upload_progress_form'+count+'" style="clear:both">&nbsp;</div>';
       str_new +='<div class="upload_form" id="f'+count+'_upload_form"><div class="attch rmailsprite"></div><div class="upld" id="upld"><div id="upl'+count+'" class="zin2" style="width:62px;overflow:hidden;cursor:pointer;float:left;position:absolute;filter: alpha(opacity=0);"><input id="myfile'+count+'" name="upfile1" type="file" class="fileclass" size="30" onchange="javascript:upload_form_attachment('+count+');" /><input type=hidden name="FormName" value="attach" /><input type=hidden name="output" value="xml" /><input type=hidden name="sid" value="5" /></div>';
        str_new +='<div class="cornLeftTop" style="float:left;"><a id="anch'+count+'" style="text-decoration: underline;" href="javascript:void(0);" onclick="javascript:test_fn('+count+');">Select file</a><span class="greyI" id="upld_inst'+count+'">(This file will start attaching once the previous file is done)</span></div>';
        str_new +='</div><div class="adjustdiv"></div></form><iframe id="upload_target'+count+'" name="upload_target'+count+'" class="upload_target" src=""></iframe>';
        document.getElementById("uploadstate").innerHTML=str_new;

这就是我生成表单的方式。它正在提交文件元素的 onchange 事件。document.getElementById("uploader"+count).setAttribute("enctype","multipart/form-data"); document.getElementById("uploader"+count).setAttribute("encoding","multipart/form-data");

我也在这里设置 enctype

4

0 回答 0