Upload | upload pictures | thumbnail 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) ' Picture gets 輟 name
Iname = The filename of the CStr (NOW.TOFILETIMEUTC) ' random (not to be restored)
Dim newnames as String = iname + newname ' re-group filename
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 thumbnails ()
Dim image, Simage as System.Drawing.Image
Image = System.Drawing.Image.FromStream (fileup. Postedfile.inputstream) ' Get the original artwork
Dim width as Decimal = image. Width over and over ' get the breadth of the original artwork
Dim height as Decimal = image. Height ' Gets the height of the original artwork
Dim Newwidth, newheight as Integer
' Set the height and width of the thumbnail
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)
' The thumbnail plus the License 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 thumbnail to simagelocal folder
Image1.visible=true;
Image1.imageurl = "simagelocal" + "\s_" + newnames
Else
Label1.Text = "Please choose a jpg type of picture"
End If
End If
End Sub