我已经成功上传了,在项目的文件夹里面能看到,但是却没有包含在VS的解决方案中
而且在前台也显示不出来着急死了。。麻烦大虾帮我看看啊。小弟不胜感激if (this.upSmallPhoto.Visible)
{
//上传小图片
string filePath = this.upSmallPhoto.PostedFile.FileName;
string fileName = this.upSmallPhoto.FileName;
string type = fileName.Substring(fileName.IndexOf("."));
string saveName = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString() + type;
string ServerPath = Server.MapPath("~/Images/") + saveName;
smallDBPath = "~/Images/" + saveName;
this.upSmallPhoto.PostedFile.SaveAs(ServerPath);
}
这是上传的一段后台代码<asp:TemplateField HeaderText="图片">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("GoodsSmallPhoto").ToString().Trim() %>' Width="80px"
Height="60px" />
</ItemTemplate>
</asp:TemplateField>
这个是前台绑定的代码。。我数据库存的是图片的地址。
~/Images/20101028172747.jpg
都是这样的现在前台就是显示不出来。急死人了麻烦帮忙看看。谢谢了
而且在前台也显示不出来着急死了。。麻烦大虾帮我看看啊。小弟不胜感激if (this.upSmallPhoto.Visible)
{
//上传小图片
string filePath = this.upSmallPhoto.PostedFile.FileName;
string fileName = this.upSmallPhoto.FileName;
string type = fileName.Substring(fileName.IndexOf("."));
string saveName = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString() + type;
string ServerPath = Server.MapPath("~/Images/") + saveName;
smallDBPath = "~/Images/" + saveName;
this.upSmallPhoto.PostedFile.SaveAs(ServerPath);
}
这是上传的一段后台代码<asp:TemplateField HeaderText="图片">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("GoodsSmallPhoto").ToString().Trim() %>' Width="80px"
Height="60px" />
</ItemTemplate>
</asp:TemplateField>
这个是前台绑定的代码。。我数据库存的是图片的地址。
~/Images/20101028172747.jpg
都是这样的现在前台就是显示不出来。急死人了麻烦帮忙看看。谢谢了
解决方案 »
- 如何用JS给下拉类表赋默认值?
- 有没有那位高人了解或看过相关"命名空间的多少与资源浪费?"
- 求C#身份证号验证函数
- 是在Xml文件查询快还是在数据库中查询快啊
- 一个网站需要登陆后才可以查看其中内容,注册用户名和密码后,能不能用程序登陆这个网站,并抓取其中的页面内容
- 研究过《ASP.NET数据库项目案例导航》一书的人进来。
- System.DBNull “DBNull”是“System”中的类型,不能用作表达式
- mvc2退出网页后,会执行什么方法?
- .NET 2.0中直接得到页面HTML代码
- 至少一个参数没有指定值?!实在看不出哪错了,大虾救命
- oracle连接超时!在线等。
- sql注入记录写入自己定义的txt文件 求 操作语句!!!
显示的时候要在< ImageUrl='<%#Eval("GoodsSmallPhoto").ToString().Trim() %>'
里面加上你的图片文件夹的路径
path+<%#Eval("GoodsSmallPhoto%>
用Image显示 html控件来显示
用html里面的那个image显示就可以了
不行就ImageUrl='Images/<%#Eval("GoodsSmallPhoto").ToString().Trim() %>'
this.upSmallPhoto.PostedFile.SaveAs(ServerPath);
this.Image1.ImageUrl = smallDBPath; <asp:Image ID="Image1" runat="server" Width="80px"
Height="60px" />这样上传完后直接显示出来也没问题。你右键查看下图片路径吧。然后改相应的代码即可
this.upSmallPhoto.PostedFile.SaveAs(ServerPath);
this.Image1.ImageUrl = smallDBPath; <asp:Image ID="Image1" runat="server" Width="80px"
Height="60px" />这样上传完后直接显示出来也没问题。你右键查看下图片路径吧。然后改相应的代码即可
右键查看图片路径
Page.ResolveUrl("~/Images/"+Eval("GoodsSmallPhoto").ToString())
但是我看了图片的路径。。是对的呀。
http://localhost:4307/Images/20101028172747.jpg
跟我的项目目录也是一样的啊。。还有个问题就是上传后的文件在VS里面是白文件。那如果不能自动包含在项目中,那以后会不会影响正常的显示呢?好纠结啊。。抓狂了要。
在上传的那个控件中加个onchange="pic_change()"
在head中加个javascript
function pic_change()
{
var pic=document.getE...ById("图片的id");
var upload=document.get...ById("FileUpLoad的id");
pic.src=upload.value;
}
大致是这样的