struts1.x 动态多附件上传

jsp




js
var attachname = "attach";
var i=1;
function addInput(){
if(i>0){
var attach = attachname + i ;
if(createInput(attach))
i=i+1;
}
}
function deleteInput(){
if(i>1){
i=i-1;
if(!removeInput())
i=i+1;
}
}
function createInput(nm){
var dv = document.createElement("div");
var aElement=document.createElement("input");
aElement.name=nm;
aElement.id=nm;
aElement.type="file";
aElement.size="43"
//aElement.value="thanks";
//aElement.οnclick=Function("asdf()");
dv.appendChild(aElement);
if(document.getElementById("upload").appendChild(dv) == null)
return false;
return true;
}
function removeInput(nm){
var aElement = document.getElementById("upload");
if(aElement.removeChild(aElement.lastChild) == null)
return false;
return true;
}


action



//取得多个附件
    Hashtable files = form.getMultipartRequestHandler().getFileElements();
    Enumeration e = files.keys();
    while (e.hasMoreElements()) {
     FormFile file = (FormFile) formBean.get(e.nextElement());
     AttBeanFactory.getInstance().createAttOtcClsreev(file, otcclsreev);
    }
效果图

你可能感兴趣的:(JSP,struts1)