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"));
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"));

本文介绍了一种ASP.NET中的图片上传方法,并演示了如何将上传的图片转换为80×80像素的缩略图。该过程包括保存原始文件、读取图片、调整尺寸并保存为PNG格式。
316

被折叠的 条评论
为什么被折叠?



