if (!String.IsNullOrEmpty(this.fileUpAddress.FileName))
{
sbFilename = new StringBuilder();
sbFilename.Append(DateTime.Now.Year);
sbFilename.Append(DateTime.Now.Month);
sbFilename.Append(DateTime.Now.Day);
sbFilename.Append(DateTime.Now.Hour);
sbFilename.Append(DateTime.Now.Minute);
sbFilename.Append(DateTime.Now.Second);
sbFilename.Append(DateTime.Now.Millisecond);
sbFilename.Append(Path.GetExtension(this.fileUpAddress.FileName));
this.fileUpAddress.SaveAs(Server.MapPath("~/images/") + sbFilename.ToString());
bool bResult = dc.SaveAdsInfo(Server.MapPath("~/images/") + sbFilename.ToString(), this.txtNavigateUrl.Text, this.txtAlternateText.Text, this.txtKeyword.Text, this.txtImpressions.Text); if (bResult)
{
Response.Write("<script>alert('保存成功')</script>");
}
else
{
Response.Write("<script>alert('保存失败')</script>");
}
}
上传完以后我检查数据库里的路径也是对的,但是运行的时候图片就是一个叉,请问是什么原因
{
sbFilename = new StringBuilder();
sbFilename.Append(DateTime.Now.Year);
sbFilename.Append(DateTime.Now.Month);
sbFilename.Append(DateTime.Now.Day);
sbFilename.Append(DateTime.Now.Hour);
sbFilename.Append(DateTime.Now.Minute);
sbFilename.Append(DateTime.Now.Second);
sbFilename.Append(DateTime.Now.Millisecond);
sbFilename.Append(Path.GetExtension(this.fileUpAddress.FileName));
this.fileUpAddress.SaveAs(Server.MapPath("~/images/") + sbFilename.ToString());
bool bResult = dc.SaveAdsInfo(Server.MapPath("~/images/") + sbFilename.ToString(), this.txtNavigateUrl.Text, this.txtAlternateText.Text, this.txtKeyword.Text, this.txtImpressions.Text); if (bResult)
{
Response.Write("<script>alert('保存成功')</script>");
}
else
{
Response.Write("<script>alert('保存失败')</script>");
}
}
上传完以后我检查数据库里的路径也是对的,但是运行的时候图片就是一个叉,请问是什么原因
解决方案 »
- 求救!Gridview 删除按钮问题
- 【随便说说】SocketTCP酒店通讯接口研究第3贴(第2贴的例子)
- 用C#新建的目录的权限问题
- 如何让gridView中的某列数据横向排列并自动换行?
- Help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!datareader转换成数组的问题!
- vs2005做网站,能不能用模板?
- while not (a>10 && b>10)的语句怎么写
- 关于绑定后数据刷新的问题。
- 怎么实现把treeview结构复制起来,生成新的treeview
- 是否可以通过C#实现更改登陆域的用户及其权限??
- [wcf]RaisePropertyChanged的信息如何在服务端获取
- 如何在数据库中新增一列 不用SQL语句
D:\Backup\%e6%88%91%e7%9a%84%e6%96%87%e6%a1%a3\Visual%20Studio%202008\WebSites\AdSystem\images\2012527225513546.jpg"
bool bResult = dc.SaveAdsInfo(Server.MapPath("~/images/") + sbFilename.ToString(), this.txtNavigateUrl.Text, this.txtAlternateText.Text, this.txtKeyword.Text, this.txtImpressions.Text);
搞定了,红色部分删掉就能看到图片了,谁能告诉我为什么。。
改成
Server.MapPath("images")应该就可以了,