protected void Button1_Click(object sender, EventArgs e)
    {
       string fullFileName= this.FileUpload1.PostedFile.FileName;//获取文件的全称   如:c://
       string fullName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);//把全称进行截取到想要的那个文件名到服务器上
       string type = fullFileName.Substring(fullFileName.LastIndexOf(".")+1);//获取图片的格式后面的那个后缀名
       if (type == "jpg" || type == "gif")
       {
           this.FileUpload1.PostedFile.SaveAs(Server.MapPath("up") + "\\" + fullName);//把图片上传到服务器上up的目录上
          // this.Image1.ImageUrl = "up/"  + fullName;
           this.Image1.ImageUrl = "up/"+fullName;
       }
       else 
       {
           Response.Write("<script language='javascript'>alert('错了')</script>");
       }
    }

解决方案 »

  1.   

    Server.MapPath("~/up/") +FileName
    看看路径
      

  2.   

    显然文件路径不对,建议使用路径转换来实现,详情请参见:《Asp.NET获取文件及其路径》http://blog.csdn.net/wonsoft/archive/2010/05/08/5570520.aspx
      

  3.   

    上传保存后显示不了 this.Image1.ImageUrl = "up/"+fullName;//改成
    this.Image1.ImageUrl=Server.MapPath("up") + "\\" + fullName;(和保存路径一致)
      

  4.   

    显示图片时,右键点些图片,查看属性,看给出的 SRC值是一个什么样子,根据这个,再修改你的代码.
      

  5.   

    上传保存后显示不了 this.Image1.ImageUrl = "up/"+fullName;//改成
    this.Image1.ImageUrl=Server.MapPath("up") + "\\" + fullName;(和保存路径一致)这个还是不行?
      

  6.   

    this.FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~/up") + "\\" + fullName);