日期:2014-05-20  浏览次数:20583 次

求助:怎样实现上传控件动态的增加,保存的时候能取到所有增加的控件选择的路径?
求助:怎样实现上传控件动态的增加,保存的时候能取到所有增加的控件选择的路径?

------解决方案--------------------
js
var name = "file ";
var file = document.createElement( " <input type=file name= "+name+ "> ");
name = name + 1;
document.Form1.appendChild(file);

aspx.cx
foreach( HttpPostedFile file in Request.Files )
{
//处理
}



------解决方案--------------------
http://dotnet.aspx.cc/ShowDetail.aspx?id=58EA3515-36F2-4FD9-AC89-EAF49F59816C
------解决方案--------------------
用一段JS动态添加控键
<script language= "javascript ">
function fileup()
{
var str = " <INPUT style= 'BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; WIDTH: 432px; BORDER-BOTTOM: 1px solid; HEIGHT: 20px ' type= 'file ' size= '52 ' name= 'File '> <br> ";
var j=document.Form1.count.value;
for(i=1;i <j;i++)
{
document.getElementById( 'td ').insertAdjacentHTML( "beforeEnd ",str);
}
}
</script>
-----------------------
private void upMorefile()
{
//遍历File表单元素
System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
//状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder( "上传的文件信息分别为: <hr color=red> ");
int fileCount,pre;
int filecount = files.Count;
string path;
path=this.DropDownList1.SelectedItem.Text;
pre=Convert.ToInt32(this.DropDownList1.SelectedValue);
if(path== "/ ")
{
path= "upedFile/ ";
}
else
{
path= "upedFile "+path;
}
try
{
for(fileCount = 0;fileCount <files.Count;fileCount++)
{
//定义访问客户端上传文件的对象
System.Web.HttpPostedFile postedFile = files[fileCount];
string fileName, fileExtension,bigtype;
//取得上传得文件名
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if(fileName != String.Empty)
{
//取得文件的扩展名
fileExtension = System.IO.Path.GetExtension(fileName);
//上传的文件信息
strMsg.Append( "上传的文件类型: " + postedFile.ContentType.ToString() + " <br> ");
strMsg.Append( "客户端文件地址: " + postedFile.FileName + " <br> ");
strMsg.Append( "上传文件的文件名: " + fileName + " <br> ");
strMsg.Append( "上传文件的扩展名: " + fileExtension + " <br> <hr color=red> ");
//保存到指定的文件夹
postedFile.SaveAs(Server.MapPath(path) + fileName);

}
}
strStatus.Text = strMsg.ToString();
div1.Visible=false;
//return true;
}
catch(System.Exception error)
{
strStatus.Text = error.Message;
//return false;

}
}

------解决方案--------------------
http://dotnet.aspx.cc/article/58ea3515-36f2-4fd9-ac89-eaf49f59816c/read.aspx