读书人

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

发布时间: 2012-05-28 17:59:33 作者: rapoo

图片地址真的很烦死人
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还想他返回什么?

读书人网 >asp.net

热点推荐