当前位置: 代码迷 >> ASP.NET >> 图片地址真的很烦死人解决思路
  详细解决方案

图片地址真的很烦死人解决思路

热度:2498   发布时间:2013-02-25 00:00:00.0
图片地址真的很烦死人
aspx.cs
C# code
string savePath = Server.MapPath("//Photo//");//string savePath = Server.MapPath("/Photo/");savePath += DateTime.Now.ToString("yyMMdd")+DateTime.Now.ToString("HHmmss") + filename;string sql_add = "insert into Photo(PhotoPath)values('" + savePath + "')";


图片路径写入数据库变成绝对路径了d:\我的文档\visual studio 2010\Projects\blog\blog\Photo\12052721052385656.jpg

真是麻烦啊,怎么调出来用啊。


aspx
HTML code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"><columns><asp:ImageField DataImageUrlField="PhotoPath" HeaderText="缩略图"></columns></asp:GridView>


------解决方案--------------------------------------------------------
你到底要什么路径?为什么要Server.MapPath计算?
------解决方案--------------------------------------------------------
一般只存一个文件名就行了。。。你Server.MapPath还想他返回什么?
  相关解决方案