多文件上传
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
/* 多文件上传 */
function addFile(){
var div1=document.getElementById("div1");
div1.innerHTML+="<div><input type='file' name='photo'/><input type='button' value='删除' onclick='delFile(this)''/></div>";
}
function delFile(input){
input.parentNode.parentNode.removeChild(input.parentNode);
}
</script>
</head>
<body>
<form enctype="multipart/form-data" action="${pageContext.request.contextPath }/uploadServlet" method="post">
<input type="text" name="name"/>
<div id=div1>
<div> <!-- 点击事件 -->
<input type="file" name="photo"/><input type="button" value="添加" onclick="addFile()"/>
</div>
<div>
<input type="file" name="photo"/><input type="button" value="删除" onclick="delFile(this)"/>
</div>
</div>
<input type="submit" value="上传"/>
</form>
</body>
</html>