Usually users upload images that need to be compressed or generated thumbnails. The resize method of System.Web.Helpers.WebImage can be used to realize this function conveniently. The sample code is as follows:
1 /// <summary>2 ///Save thumbnail image3 /// </summary>4 /// <param name= "file" >user-uploaded files</param>5 /// <param name= "FileName" >the file name you want to save</param>6 /// <param name= "Uploadpath" >Upload Address</param>7 /// <returns></returns>8 Private BOOLSavethumbfile (httppostedfilebase file,stringFileName,stringUploadpath,intPostID)9 {Ten Try One { A varThumbimage =Newwebimage (file. InputStream); -Thumbimage.resize ( the, the); - varThumbpath = Path.Combine (Server.MapPath ("~/content/uploads/images/thumb"), the fileName); - Thumbimage.save (thumbpath); - return true; - } + Catch - { + return false; A } at}