利用jQuery实现多文件上传
protected void btnUpload_Click(object sender, EventArgs e)
{
try
{
// 获取文件列表
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("MyFiles") + "\\" +
System.IO.Path.GetFileName(hpf.FileName));
Response.Write("<b>文件: </b>" + hpf.FileName + " <br/> <b>大小:</b> " +
hpf.ContentLength + " <br/> <b>类型:</b> " + hpf.ContentType + " 上传成功! <br/>");
}
}
}
catch (Exception ex)
{
}
}
{
try
{
// 获取文件列表
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("MyFiles") + "\\" +
System.IO.Path.GetFileName(hpf.FileName));
Response.Write("<b>文件: </b>" + hpf.FileName + " <br/> <b>大小:</b> " +
hpf.ContentLength + " <br/> <b>类型:</b> " + hpf.ContentType + " 上传成功! <br/>");
}
}
}
catch (Exception ex)
{
}
}