CSDN博客

img xiaoK

上传图片并修改其大小(转载)

发表于2004/12/30 20:00:00  846人阅读

上传图片并修改其大小
//thefile是一个File Field HTML 控件
thefile.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath("temp.png"));
MemoryStream MemStream=new MemoryStream();
System.Drawing.Image imgOutput =System.Drawing.Bitmap.FromFile(System.Web.HttpContext.Current.Server.MapPath("temp.png"));
//修改成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(thefile.PostedFile.FileName);
Response.Write("Len:"+MemStream.Length.ToString());
imgOutput.Dispose();
imgOutput2.Dispose();
Response.Write("上传成功!");
Response.Write(System.Web.HttpContext.Current.Server.MapPath("image.png"));
0 0

相关博文

我的热门文章

img
取 消
img