Upload a picture and modify its size (C #)

Source: Internet
Author: User
Tags httpcontext modify
Upload pictures upload pictures and modify their size
Thefile is a file Field HTML control
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 "));
Modified to 80x80 size
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 ("Upload success!");
Response.Write (System.Web.HttpContext.Current.Server.MapPath ("image.png"));
-----------------------------------------
What is it like to float? Heaven and earth a gull.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.