上傳圖片並修改其大小
//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
));
//修改成
×
大小
System
Drawing
Image imgOutput
=imgOutput
GetThumbnailImage(
null
IntPtr
Zero);
imgOutput
Save(System
Web
HttpContext
Current
Server
MapPath(
image
png
)
ImageFormat
Png);
Response
Write(thefile
PostedFile
FileName);
Response
Write(
Len:
+MemStream
Length
ToString());
imgOutput
Dispose();
imgOutput
Dispose();
Response
Write(
上傳成功!
);
Response
Write(System
Web
HttpContext
Current
Server
MapPath(
image
png
));
From:http://tw.wingwit.com/Article/program/net/201311/13582.html