<% @ Page language = "c #" responseEncoding = "GB2312"%> <% @ import namespace = "system"%> <% @ import namespace = "system.io"%> <% @ import namespace = "system.drawing "%> <% @ import namespace =" system.drawing.imaging "%>
void Page_Load (Object sender, EventArgs e) {if {ImgPreview.Visible = false (Page.IsPostBack!);}} 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 = 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; i Mgpreview.imageurl = newfile;} Bool thumbnailcallback () {return true;}
void Button_Click (object sender, EventArgs e) {int width, height, left, right; string 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 Selection File";} else {
String path = server.mappath ("./ UPLOADS /" UPLOADFILE.POSTEDFILE.FILENAME.SUBSTED (UPLOADE.POSTEDFILE.FILENAME.LASTINDEXOF ('' // ') 1); if (file.exists (path) ) {lblerrinfo.text = "There is already the same name file";} else {UPLOADFILE.POSTEDFILE.SAVEAS (PATH); GetthumbnailImage (Width, Height, straddInfo, Left, Right);}}} script>
head>