I'm not going to say much.
if(request.files["file1"] ==NULL) {Response.Write ("<script>alert (\ "Please select Upload file!\") </script>"); } Else { //Get Picture Format stringFileExtension = Path.getextension (request.files["file1"]. FileName); if(FileExtension = =". jpg") { //Picture Save Path stringSavepath = Server.MapPath (@"~/uploadpic/"); //take the picture streamStream Sam = request.files["file1"]. InputStream; //take the picture stream and save the image .System.Drawing.Image im =System.Drawing.Image.FromStream (SAM); //Original Width intOwidth =im. Width; //Original Height intOheight =im. Height; //set thumbnail initial width intTwidth = About; //set thumbnail initial height intTheight = the; //create an empty BMP pictureBitmap BT =NewBitmap ( About, the); //calculates the width and height of the thumbnail proportionally if(Owidth >=oheight) Theight= (int) Math.floor (convert.todouble (oheight) * (convert.todouble (twidth)/convert.todouble (owidth)); ElseTwidth= (int) Math.floor (convert.todouble (owidth) * (convert.todouble (theight)/convert.todouble (oheight)); //Center Picture intPWidth = ( About-Twidth)/2; intPheight = ( the-Theight)/2; //create an instance of a drawing pictureGraphics g =Graphics.fromimage (BT); //Control picture qualityG.interpolationmode =System.Drawing.Drawing2D.InterpolationMode.Low; //control anti-aliasingG.smoothingmode =System.Drawing.Drawing2D.SmoothingMode.HighQuality; //Set Transparent Backgroundg.clear (color.transparent); //generate thumbnail imagesG.drawimage (IM,NewRectangle (PWidth, Pheight, Twidth, Theight),NewRectangle (0,0, Owidth, oheight), GraphicsUnit.Pixel); //Save PictureBt. Save (string. Format ("{0}{1}.png", Savepath, DateTime.Now.ToString ("yyyymmddhhmmss_yyyy") ), imageformat.png); } Else{Response.Write ("<script>alert (\ "Picture format is incorrect!\") </script>"); } }
Reprint Please specify!
C # ASP. NET scale-down code (Basic edition)