保存图片

Bitmap empPic;
   try
   {
    empPic = new Bitmap(File1.PostedFile.InputStream);
   }
   catch
   {
    lblErr.Text = "错误文件格式,请重试!!";
    lblErr.Visible = true;
    return;
   }
   lnkPic.Src = File1.PostedFile.FileName;










Bitmap empPic;
    try
    {
     empPic = new Bitmap(lnkPic.Src);
    }
    catch
    {
     lblErr.Text = "错误文件格式,请重试!!";
     lblErr.Visible = true;
     return;
    }
    Bitmap picSmall = new Bitmap(empPic,110,130);
    MemoryStream stream = new MemoryStream();
    picSmall.Save(stream,ImageFormat.Jpeg);
    byte[]  byteArray = stream.ToArray();
    int empID = Convert.ToInt16(lblEmpID.Text,10);
    MrBaseInf PhotoAccess = new MrBaseInf();
    PhotoAccess.UpdateEmpPic(empID,byteArray);
    Response.Redirect("empbase.aspx?empid="+lblEmpID.Text,false);
原文地址:https://www.cnblogs.com/lingxzg/p/504170.html