上传图片并修改其大小(C#)

来源:互联网 发布:11选五任五遗漏数据 编辑:程序博客网 时间:2024/05/16 10:30
  FileUpload1.PostedFile.SaveAs(Server.MapPath("~/image/"+FileUpload1.FileName));
        MemoryStream MemStream = new MemoryStream();
        System.Drawing.Image imgOutput = System.Drawing.Bitmap.FromFile(Server.MapPath("~/image/" + FileUpload1.FileName));
        //修改成80×80大小
        System.Drawing.Image imgOutput2 = imgOutput.GetThumbnailImage(80, 80, null, IntPtr.Zero);
        imgOutput2.Save(System.Web.HttpContext.Current.Server.MapPath("image.png"), ImageFormat.Png);
        Response.Write(FileUpload1.PostedFile.FileName);
        Response.Write("Len:" + MemStream.Length.ToString());
        imgOutput.Dispose();
        imgOutput2.Dispose();
        Response.Write("上传成功!");
        Response.Write(System.Web.HttpContext.Current.Server.MapPath("image.png"));
原创粉丝点击