我有一个包含多个文件上传表单的页面。这是循环生成的。
问题:第一个文件上传控件有效,其余的没有。
<div>
<form action="/docs/1046/UploadDocument?Id=1046&propertyTypeId=1" enctype="multipart/form-data" method="post">
<input name="X-HTTP-Method-Override" type="hidden" value="PUT">
<div style="display: none">
<label for="fileCOMMERCIAL_TRANSPORT_LICENSE"></label>
<input id="fileCOMMERCIAL_TRANSPORT_LICENSE" name="fileCOMMERCIAL_TRANSPORT_LICENSE" type="file" onchange=" $('#btnSubmitData').click(); ">
<input id="btnSubmitData" type="submit" onclick=" txt = $('#fileCOMMERCIAL_TRANSPORT_LICENSE').val(); alert(txt); ">
</div>
<div>
<label>
Document 1:
</label>
<button type="button" onclick=" $('#fileCOMMERCIAL_TRANSPORT_LICENSE').click(); ">Upload 1</button>
</div>
</form>
<form action="/docs/1046/UploadDocument?Id=1046&propertyTypeId=5" enctype="multipart/form-data" method="post">
<input name="X-HTTP-Method-Override" type="hidden" value="PUT">
<div style="display: none">
<label for="fileCLEAN_CRIMINAL_RECORD"></label>
<input id="fileCLEAN_CRIMINAL_RECORD" name="fileCLEAN_CRIMINAL_RECORD" type="file" onchange=" $('#btnSubmitData').click(); ">
<input id="btnSubmitData" type="submit" onclick=" txt = $('#fileCLEAN_CRIMINAL_RECORD').val(); alert(txt); ">
</div>
<div>
<label>
Document 2:
</label>
<button type="button" onclick=" $('#fileCLEAN_CRIMINAL_RECORD').click(); ">Upload 2</button>
</div>
</form>
</div>
答案 0 :(得分:1)
使您的ID #btnSubmitData唯一。这应该可以解决问题。
答案 1 :(得分:0)
我不知道您的问题是什么,但有时请确保您的输入具有不同的名称:
<form action="...">
<input type="file" name="firstFile" /> //other names
<input type="file" name="secondFile" />
<input type="submit" value="send" />
</form>