首先说ActionForm
Action里面就这样处理
再看HTML文件
public class AykjArtistForm extends ActionForm{
//有那么麻烦吗,还要写什么LIST在里面,不用的..当然了其它参数就看你的情况了
}
Action里面就这样处理
ArrayList list= new ArrayList();//用来装FormFile
Hashtable fileh = form.getMultipartRequestHandler().getFileElements();//form是传过来的参数
for(Iterator it = fileh.keySet().iterator(); it.hasNext();){
String key = (String) it.next();
FormFile formfile = (FormFile) fileh.get(key);//获取一个FormFile
list.add(formfile);//装进去
}
再看HTML文件
<div id="artist">
<div id="myupload0">
<input type="file" id="file0" name="photo(0)" onchange="addinput(0)">
</div>
</div>
//js文件
<script type="text/javascript">
var i = 0;
function addinput(numline){
var divid = "divid"+(numline+1);
if(document.getElementById(divid)){
return;
}
i++;
var myHTML = "<input type='file' id='file"+(numline+1)+"' name='photo("+(numline+1)+")' onchange='addinput("+(numline+1)+")'>";
var pdiv = document.getElementById("artist");
var div = document.createElement("div");
var divids = "divid"+(numline+1)
div.setAttribute("id",divids);
/*var inputHTML = document.createElement("input");*/
/*var inputHTMLnum = "artistPhoto("+numline+")";*/
div.innerHTML = myHTML;
/*div.appendChild(inputHTML);*/
pdiv.appendChild(div);
}
</script>