0

hello programers

i made upload pic from my pc to the project folder so i need to diplay this pic on web page
i m using ASP.net with Vb

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    If Me.FileUpload1.PostedFile.FileName = Nothing Then
        Me.Label3.Text = "nothing choosed to upload "
        Exit Sub

    End If

    Dim fpath As String = Server.MapPath("imgs") & "\" & IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
    IO.Path.GetExtension(fpath)


    Me.Label3.Text = "successful"
    Exit Sub


    If FileUpload1.PostedFile.InputStream.Length > 372000 Then
        Me.Label3.Text = "it is too long "
        Exit Sub

    End If

    If IO.File.Exists(fpath) = True Then
        Me.Label3.Text = "the file is exist try another name "
        Exit Sub
    End If

    FileUpload1.PostedFile.SaveAs(fpath)
End Sub

so how can i call the pic i had uploaded to the website folder and show it in the web page , or i must save it on a database ,
hope i can find answer here :)

2
Contributors
4
Replies
10
Views
3 Years
Discussion Span
Last Post by JorgeM
1

If you want to simply display what was uploaded, well there are a few different approaches.

I think the easiest way is to have an image control that by default is set to visible = false, then on the postback where you click on the button to upload, after you save the file, you already know the path to the where the file was saved. So take that path and assign it to the image's source property and set the image to visible = true.

0

haha,Thank you , i liked ur idea , i will use it for sure , but it will be heavy for the website when it is working , wut i f i wanna call the path which i have uploaded and send it to the source for image url , do u think it will work

0

i ahve another trouble when i upload the pic it doesnt work immmediately just after closing the asp program and turn it on i find it in the folder and uploaded , may u help me in this

0

it doesnt work immmediately just after closing the asp program and turn it on i find it in the folder and uploaded ,

not sure what you mean by that. If you have updated the src attribute of the image, when the page reloads, it should show the pic.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.