日期:2014-05-17 浏览次数:20578 次
<head>
<script>
function createFileButton(){
var div=document.getElementById("uploadDiv");
var fileButton=document.createElement("input");
fileButton.type="file";
fileButton.name="files";
var removeButton=document.createElement("input");
var br=document.createElement("br");
removeButton.type="button";
removeButton.value="删除";
removeButton.onclick=function(){
div.removeChild(fileButton);
div.removeChild(removeButton);
div.removeChild(br);
}
div.appendChild(fileButton);
div.appendChild(removeButton);
div.appendChild(br);
}
</script>
</head>
<body>
<form action="upload.action" enctype="multipart/form-data" method="post">
<div id="uploadDiv">
<input type="file" name="files"/><input type="button" onclick="createFileButton()" value="新增"/><br>
</div>
<input type="submit" value="提交"/>
</form>
</body>
var fileInput=document.createElement("input");
fileInput.type="file";
fileInput.name="files";
document.getElementById("你图片添加div的Id").appendChild(fileInput);
public UploadAction extends ActionSupport{
private List<File> files;
public void setFiles(List<File> files){
this.files=files;
}
public List<File> getFiles(){
return files;
}
}