首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-05-28 
图片地址真的很烦死人aspx.csC# codestring savePath Server.MapPath(//Photo//)//string savePath

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

热点排行