CreateElements.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>上传多个文件</title> <script language="javascript" type="text/javascript"> <!-- var num=0; var BeforValue=""; function Creat() { num++; var i; var str; var Upf=document.getElementById("Upf"); var file=document.createElement("<input type='file' id='file" + num + "' size='40' onchange='AddFile(this.value)'onkeypress='return false;' onpaste='return false;' onmousedown='return false;' onkeydown='return false;' onfocus='return false;' onclick='BeforValue=this.value' />"); var href=document.createElement("<a href='javascript:void(0)' onclick='remove(" +num +")' id='h"+num+"'>"); var hrefText=document.createTextNode("[删除]"); href.appendChild(hrefText); var br=document.createElement("<br id='b"+num+"'>"); Upf.appendChild(file); Upf.appendChild(href); Upf.appendChild(br); } function DelFile(num) { var obt=document.forms[0].FileValue var delText=document.getElementById("file"+num).value; var text=obt.value; if (text.indexOf("&"+delText)>=0) delText="&"+delText text = text.replace(delText, ""); obt.value=text; } function DelFileValue(value) { var obt=document.forms[0].FileValue var delText=value; var text=obt.value; if (text.indexOf("&"+delText)>=0) delText="&"+delText; else if (text.indexOf(delText+"&")>=0) delText=delText+"&"; text = text.replace(delText, ""); obt.value=text; } function remove(value) { DelFile(value); var Upf=document.getElementById("Upf"); var re=document.getElementById("file"+value); var re2=document.getElementById("h"+value); var re3=document.getElementById("b"+value); Upf.removeChild(re); Upf.removeChild(re2); Upf.removeChild(re3); } function AddFile(value) { if (BeforValue !="") DelFileValue(BeforValue); var vValue=document.forms[0].FileValue.value; if (vValue=="") vValue+=value; else vValue+=("&"+value); document.forms[0].FileValue.value=vValue; } //--> </script> </head> <body> <form action="MyUpFiles.asp" method="post" > <div id="Upf"></div> [<a href="javascript:void(0)" onclick="Creat()">添加一个</a>]<br /> <input type="submit" name="Submit" value="提交"/> <input name="FileValue" type="hidden" id="FileValue" size="100"/> </form> </body> </html> MyUpFiles.asp <% Function GetFileName(ByVal strFile) If strFile <> "" Then GetFileName = mid(strFile,InStrRev(strFile, "")+1) Else GetFileName = "" End If End Function sValues=request.Form("FileValue") UpLoadFolder="" if (left(sValues,1)="&") then sValues=right(sValues,len(sValues)-1) end if svalue=split(sValues,"&") for i=0 to ubound(svalue) strFileName = svalue(i) Response.Write("第"& i+1 & "个上传到:" & (UpLoadFolder & "" & GetFileName(strFileName))&"<br>") Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type = 1 ' adTypeBinary objStream.Open objStream.LoadFromFile strFileName objStream.SaveToFile Server.MapPath(UpLoadFolder & "" & GetFileName(strFileName)),2 objStream.Close next %> 这个上传方法比较笨,不过能通过路径来上传文件,如果你有更好的上传文件类,麻烦发份给我,谢谢了~ 最好能给路径就能上传的类~~