请教文件上传问题 if (FileUpload1.HasFile){}else{ error} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //多附件上传 for (int i = 0; i < fc.Count; i++) { if (fc[i].FileName != "") { string filePhysicalPath = ""; try { HttpPostedFile hPostedFile = fc[i]; int Filelong = hPostedFile.ContentLength; if (Filelong > Convert.ToInt32(ConfigurationManager.AppSettings["FileZize"].ToString())) { Response.Write("<script>alert('" + "文件过大,上传失败!" + "');</script>"); return; } string RandomString = Convert.ToString(Guid.NewGuid()); string TrueName = Path.GetFileName(fc[i].FileName); string ExtendName = TrueName.Substring(TrueName.LastIndexOf(".")); string RandomName = RandomString + ExtendName; filePhysicalPath = Server.MapPath("~/UpLoad/DepartmentWork/" + RandomName); if (!Directory.Exists(filePhysicalPath)) { Directory.CreateDirectory(Server.MapPath("~/UpLoad/DepartmentWork/")); } fc[i].SaveAs(filePhysicalPath); db.AddAttach(RandomName, AddID, TrueName); log.AddLog("添加", "", "信息标题为:《" + txtname.Text + "》的《" + TrueName + "》附件"); } catch { Response.Write("<script language=javascript>alert('上传文件出错!');</script>"); } } } 求正则表达式 一个ASP.NET项目,想支持多种数据库,数据层如何写? 求解!gridview GridView 删除或更新某一行,只去除或更新GridView中的记录,不更新数据库! JS IE和FireFox兼容的问题 C#画动态曲线 请教css技术问题 请教,有没有在网页中可直接打开并能编辑Word的插件? 不用存贮过程,这样的参数能传递吗? strsql="select top @num * from table1"? 一个关于触发事件的问题 关于上传文件的问题——为什么总出错:“未将对象引用到对象的实例” 教大家如何赚YHB access到底有什么限制?请进来看看.在线等
for (int i = 0; i < fc.Count; i++)
{
if (fc[i].FileName != "")
{
string filePhysicalPath = "";
try
{
HttpPostedFile hPostedFile = fc[i];
int Filelong = hPostedFile.ContentLength;
if (Filelong > Convert.ToInt32(ConfigurationManager.AppSettings["FileZize"].ToString()))
{
Response.Write("<script>alert('" + "文件过大,上传失败!" + "');</script>");
return;
}
string RandomString = Convert.ToString(Guid.NewGuid());
string TrueName = Path.GetFileName(fc[i].FileName);
string ExtendName = TrueName.Substring(TrueName.LastIndexOf("."));
string RandomName = RandomString + ExtendName;
filePhysicalPath = Server.MapPath("~/UpLoad/DepartmentWork/" + RandomName);
if (!Directory.Exists(filePhysicalPath))
{
Directory.CreateDirectory(Server.MapPath("~/UpLoad/DepartmentWork/"));
}
fc[i].SaveAs(filePhysicalPath); db.AddAttach(RandomName, AddID, TrueName);
log.AddLog("添加", "", "信息标题为:《" + txtname.Text + "》的《" + TrueName + "》附件");
}
catch
{
Response.Write("<script language=javascript>alert('上传文件出错!');</script>");
}
}
}