Monday, May 10, 2010

Image Upload Example With Code in VB



Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupload.Click


If Path.GetExtension(fileupld.PostedFile.FileName).ToString.ToLower = ".jpg" Then
Dim filename As String
filename = DateTime.Now.ToString("ddMMyyyyhhmmss") & Path.GetFileName(fileupld.PostedFile.FileName)
hdnfield.Value = filename
fileupld.PostedFile.SaveAs(Server.MapPath("photo") & "/" & filename)
WebMsgBox.Show("Photo Uploaded Successfully")
EmpImage1.ImageUrl = "~/Photo/" & filename
Else
WebMsgBox.Show(" incorrect File")
End If
End Sub