jsp页面代码
<form method="post" action="" enctype="multipart/form-data"> <table> <tr> <td align="right"> 请选择上传的文件: </td> <td> <input id="file" name="file" type="file" size="35"> <input type="button" value="添加" onclick="addRow()"> </td> </tr> <tr style="display: none;" id="myTr"> <td align="right"> 请选择上传的文件: </td> <td> <input id="file" name="file" type="file" size="35"> <input type="button" value="删除" onclick="delRow(this)"> </td> </tr> </table> </form>
js
<script type="text/javascript">
function addRow()
{
var tr = document.getElementById("myTr");
var con = tr.cloneNode(true);
con.removeAttribute("style");
tr.parentNode.insertAdjacentElement("beforeEnd",con);
}
function delRow(obj)
{
var tr=obj.parentNode.parentNode;
tr.parentNode.removeChild(tr);
}
</script>
action代码
public class testAction{ private File[] file; private String[] fileFileName; //生成get set方法 遍历上传 }