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还想他返回什么?