asp.net Image与FileUpLoad控件

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:25:49
请问我用 一个FileUpLoad上传一图片 同时Image控件显示
代码
string b = Request.MapPath(@"~/Hello\");

string a = this.FileUpload1.FileName;
if (FileUpload1.HasFile)
{
this.FileUpload1.PostedFile.SaveAs(b + a);
string c = b + a;
this.Response.Write(c);
this.Image1.ImageUrl = Request.MapPath(@"~/Hello\" + this.FileUpload1.FileName);
}
页面回送了 不显示图片

this.Image1.ImageUrl ="~/Hello/" + this.FileUpload1.FileName就可以了
QQ:632175205

this.Image1.ImageUrl = Server.MapPath(b + a);

如果页面回送后没有显示图片,可以在图片控件上点击右键 属性,看看这个控件的url指向哪里!

路径格式错误