i used this code to upload the images from the local path. but when i'm trying to upload the images in the webpage it is not showing. can any one can tell what's wrong in the coding. it will be very helpful.........................

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        ImageMap1.AlternateText = ""
        If FileUpload1.HasFile Then
            Try
                If (FileUpload1.PostedFile.FileName.EndsWith(".jpg")) Then
                    FileUpload1.SaveAs("C\Documents and Settings" & _FileUpload1.FileName)
                    ImageMap1.AlternateText = "uploaded sucessfully....." & "<br>" & "File name: " & _
                           FileUpload1.PostedFile.FileName & "<br>" & _
                           "File Size: " & _
                           FileUpload1.PostedFile.ContentLength & " kb<br>" '& 
                Else
                    ImageMap1.AlternateText = "Not a valid file."
                End If
            Catch ex As Exception
                ImageMap1.AlternateText = "ERROR: " & ex.Message.ToString()
            End Try
        Else
            ImageMap1.AlternateText = "You have not specified a file."
        End If
    End Sub

please help me... need it very urgently.
thanks a lot

Try to save image or any uploaded file into sub-folder under your webapplication root.

For example,

IF FileUpload1.FileBytes.Length<>0 Then   
   Dim target as String ="~/images/" & FileUpload1.FileName
   FileUpload1.SaveAs(MapPath(target))
   Image1.ImageUrl=target
End If

thanks for the code it's working

this is the code for uploading images.....................................................

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        If FileUpload1.HasFile Then
            Try
                If (FileUpload1.PostedFile.FileName.EndsWith(".jpg")) Then
                    If FileUpload1.FileBytes.Length <> 0 Then
                        Dim target As String = "~/pictures/" & FileUpload1.FileName
                        FileUpload1.SaveAs(MapPath(target))
                        Image1.ImageUrl = target
                    End If

                Else
                End If
            Catch ex As Exception

            End Try
        Else

        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.