Sub upimages () Dim iname As String If Not (fileup.PostedFile Is Nothing) Then Dim namestr1 As String = (fileup.PostedFile.FileName) If LCase (fileup.PostedFile.ContentType.ToString ()) = "image / pjpeg" Or LCASE (fileup.postedfile.contentType.toString ()) = "image / jpg" THEN DIM J AS Integer = nameStr1.lastIndexof (".") DIM NewName As String = NameStr1.substring (j) 'Image Lose INAME = CSTR (NOW.TOFILETIMEUTC) 'Random file name (no repeated) DIM newnames as string = iname newname' Re-combined file name DIM i as integer = namestr1.lastIndexof ("/") 1 Dim Namestr as string = NameStr1.Substring (i) fileup.postedfile.saveas (server.mappath (imagelocal) "/" newnames) 'Save File to ImageLocal Folder' Generate Thumbnail () DIM Image, Simage As System.drawing.Image Image = System.drawing.Image.fromstream (fileup.postedfile.inputstream) 'Get the original picture Dim width as decimal = image.width over and over' get the original image Dim height As Decimal = image.Height 'to obtain a high picture Dim newwidth, newheight As Integer' set the thumbnail width and height of If (width> height) Then newwidth = 150 newheight = CInt (height / width * 150) Else newheight = 150 newwidth = CInt (width / height * 150) End If sImage = image.GetThumbnailImage (newwidth, newheight, Nothing, IntPtr.Zero) Dim x As Integer = sImage.Width / 2 - 30 Dim y As Integer =
SIMAGE.HEIGHT - 20 DIM OUTPUT AS Bitmap = New Bitmap (Simage) DIM G AS Graphics = graphics.fromImage (output) Add copyright information () DIM FONTS AS NEW FONT ("Courier New", 9) g .Drawstring ("Copyright Information", Fonts, New Solidbrush (Color.red), X, Y) Output.save (Server.MAppath ("SimageLocal") "/ S_" NewNames, System.drawing.Imaging.ImageFormat. JPEG) 'Save thumbnails to SimageLocal folder image1.visible = true; image1.imageURL = "simagelocal" "/ s_" newnameselse label1.text = "Please select a picture of JPG type"
END if end if End Sub