The code is as follows:
<%@ page language= "C #" responseencoding= "gb2312"%> <%@ import namespace= "System"%> <%@ import namespace= "System.IO"%> <%@ Import namespace= "System.Drawing"%> <%@ import namespace= "System.Drawing.Imaging"%> <script runat= "Server" > void Page_Load (Object sender, EventArgs e) {if (! Page.IsPostBack) {imgpreview.visible=false;}} void getthumbnailimage (int width,int height,string strinfo,int left,int right) {string file= "uploads/" + UploadFile.PostedFile.FileName.Substring (uploadFile.PostedFile.FileName.LastIndexOf (' \ \ ') +1); String newfile= "uploads/" +uploadfile.postedfile.filename.substring (UploadFile.PostedFile.FileName.LastIndexOf (' \ \ ') +1 + ". jpg"; String Stradd=strinfo; System.Drawing.Image oldimage = System.Drawing.Image.FromFile (Server.MapPath (file)); System.Drawing.Image thumbnailimage = oldimage. Getthumbnailimage (width, height,new System.Drawing.Image.GetThumbnailImageAbort (thumbnailcallback), IntPtr.Zero); Response.Clear (); Bitmap output=nEW Bitmap (thumbnailimage); Graphics g=graphics.fromimage (output); g.DrawString (stradd,new Font ("Courier new", New SolidBrush (color.red), left,right); Output. Save (Server.MapPath (newfile), System.Drawing.Imaging.ImageFormat.Jpeg); Response.ContentType = "Image/gif"; Imgpreview.visible=true; Imgpreview.imageurl=newfile; } bool Thumbnailcallback () {return true;} void Button_Click (object sender, EventArgs e) {int width,height,left,right; s Tring Straddinfo=txtaddinfo.text; Width=int32.parse (Txtwidth.text); Height=int32.parse (Txtheight.text); Left=int32.parse (Txtleft.text); Right=int32.parse (Txtright.text); if (! ( uploadfile.postedfile.contentlength>0) {lblerrinfo.text= "no file selected";} else {string path = Server.MapPath ("./uploads /"+uploadfile.postedfile.filename.substring (uploadFile.PostedFile.FileName.LastIndexOf (' \ \ ') +1)); if (path) {lblerrinfo.text= "already has a file with the same name";} else {uploadFile.PostedFile.SaveAs (path); file.exists; Getthumbnailimage (Width,height,straddinfo,left,right); }}} </SCRipt>