asp.net form表单 enctype ="multipart/form-data" 取值 只能上传文件,数据库数据未被修改 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Request就可以获取表单内容,查一下SQL enctype ="multipart/form-data"好像是这个的问题,设成这个就取不了表单的值 <form id="form1" runat="server" enctype="multipart/form-data"> <div> <input id="File1" type="file" name="upFiles" /> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div></form>protected void Button1_Click(object sender, EventArgs e) { HttpPostedFile postFiles = Request.Files[0]; string fileName = postFiles.FileName; Response.Write(fileName); } <%@ Page Language="C#" Debug="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (Request.RequestType == "POST") { HttpPostedFile postedFile = Request.Files["File1"]; string fileName; fileName = System.IO.Path.GetFileName(postedFile.FileName); postedFile.SaveAs(Request.MapPath("~/") + fileName); Response.Write("输入的内容 = " + Request.Form["Title"]); //插入数据库即可 } } </script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form method="post" enctype="multipart/form-data"> <input name="File1" type="file" /> <input name="Title" value="文字" /> <input id="Submit1" type="submit" value="submit" /> </form></body></html> file 控件 private string GetTRStrFile(string aa, string bb, string cc, int num) { string returnString = ""; returnString += "<td class=\"style5\">"; returnString += "<span lang=\"zh-cn\" id=\"span" + aa + "\">" + bb + "</span></td>"; returnString += "<td align=\"left\" onmouseover=\"this.className='t_rowh'\" onmouseout=\"this.className='t_row'\"style=\"height: 16px\" colspan=\"3\">"; returnString += "<input id=\"input" + aa + "\" type=\"file\" name=resume" + num + " value=\"" + cc + "\" style=\"width:388px\" /></td>"; return returnString; } 提交表单按钮protected void BtnSubmit_Click(object sender, EventArgs e) { ArrayList resume = new ArrayList(); while (i > 0) { if (Request.Form["resume" + i] != null) { resume.Add(Request.Form["resume" + i]); i++; } else { break; } } string[] array = (string[])resume.ToArray(Type.GetType("System.String")); int n = DataAccess.Repeat.UpdateRepeatTable(tablename, array, tableide);}我知道 filename 就是文件名 可是怎么放到数组里呢 项目上文件状态显示不正确,vss的问题? 很是奇怪 ajax.dll 引用的问题 IE 的 back 引起的问题 有没有研究过MSN的BLOG? ADO.NET的一个问题 请问为什么不能绑定数据? 为什么radiobutton的oncheckedchanged当选项改变时并不能触发,非得提交一下才会处理事件? 有没有什么方法可以IE页面里显示CAD文件和Visio文件 我的asp.net无法调试,告诉我说我不是“调试器用户“,如何添加 如何判断一个页面已经被关闭? 这个问题怎么解决? SQL模糊查询问题
好像是这个的问题,设成这个就取不了表单的值
<div>
<input id="File1" type="file" name="upFiles" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
</form>
protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile postFiles = Request.Files[0];
string fileName = postFiles.FileName;
Response.Write(fileName);
}
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (Request.RequestType == "POST")
{
HttpPostedFile postedFile = Request.Files["File1"];
string fileName;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
postedFile.SaveAs(Request.MapPath("~/") + fileName); Response.Write("输入的内容 = " + Request.Form["Title"]);
//插入数据库即可
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input name="File1" type="file" />
<input name="Title" value="文字" />
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
private string GetTRStrFile(string aa, string bb, string cc, int num)
{ string returnString = "";
returnString += "<td class=\"style5\">";
returnString += "<span lang=\"zh-cn\" id=\"span" + aa + "\">" + bb + "</span></td>";
returnString += "<td align=\"left\" onmouseover=\"this.className='t_rowh'\" onmouseout=\"this.className='t_row'\"style=\"height: 16px\" colspan=\"3\">";
returnString += "<input id=\"input" + aa + "\" type=\"file\" name=resume" + num + " value=\"" + cc + "\" style=\"width:388px\" /></td>";
return returnString; } 提交表单按钮
protected void BtnSubmit_Click(object sender, EventArgs e)
{
ArrayList resume = new ArrayList();
while (i > 0)
{
if (Request.Form["resume" + i] != null)
{
resume.Add(Request.Form["resume" + i]);
i++;
}
else
{
break;
}
}
string[] array = (string[])resume.ToArray(Type.GetType("System.String"));
int n = DataAccess.Repeat.UpdateRepeatTable(tablename, array, tableide);
}
我知道 filename 就是文件名 可是怎么放到数组里呢