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 :)

Recommended Answers

All 4 Replies

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.

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

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

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.

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.