954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Uploading picture (browse for picture)

Please all, I am a young female programmer who designed a form. In the form there is a field for image. How will i add a browse to it so that the person felling the form will browse to pick the picture from his system.

Please ATTEND URGENTLY TO IT.
TANX.

omotoyosi
Light Poster
44 posts since Dec 2007
Reputation Points: 7
Solved Threads: 1
 

If you are using VS you can drag an OpenFileDialog, 3 buttons, textbox and a picturebox to your form.
With your first button (Browse). In this buttons click event add

OpenFileDialog.Title = "Get Image"
OpenFileDialog.ShowDialog()

Go back to your form and double click the OpenFileDialog. Add this code

textbox.text = OpenFileDialog.FileName


go to your second button (Upload) click event and add

if (textbox.text.Trim() <> "") Then
PictureBox.Image = Image.FromFile(textbox.text)


Finally in the third button (Remove). Open the click event for this button and add.

Picturebox.image = Nothing


this should take care of browsing, displaying path, uploading and removing the image from your form.

ProfessorPC
Posting Whiz in Training
270 posts since Dec 2007
Reputation Points: 31
Solved Threads: 29
 

add/drag opendialog control in your form , one label (for path view), one picture box (for image view) and one button (for browse image).
in your button browse add this code :

With OpenFileDialog1
            '.InitialDirectory = "C:\"
            .Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
            .FilterIndex = 4
        End With

        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            PictureBox1.BorderStyle = BorderStyle.Fixed3D
            lblFilePath.Text = OpenFileDialog1.FileName()
        End If

you can change the filter index to set image extension at first open. in this code filter index = 4 will set to jpeg, so when first open just jpeg image will shown. change filter index as u need.

Ok. all for the best

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

tanx,
I realy apreciated ur concern.it has worked.
Another problem is on the deploying, if i install on another system it will not see the connection. why this i saved the database in my d: drive. pls. help.

omotoyosi
Light Poster
44 posts since Dec 2007
Reputation Points: 7
Solved Threads: 1
 

can you specify the problem please...

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

must love Google translations... maybe posting in the native language would make it easier to understand. (ok, that was a little mean.)

ericstenson
Posting Whiz in Training
Team Colleague
295 posts since Dec 2007
Reputation Points: 14
Solved Threads: 29
 

How is upload the picture in vb.net

mahender.B
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

How to upload image and how to store images from database

mahender.B
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Dim UploadFileControl As FileUpload
UploadFileControl = ImageFieldID
If UploadFileControl.HasFile Then
UpldFile.Add(UploadFileControl)
// check for extention of the file
if exist()
// save the image

End If

vmreddy
Newbie Poster
3 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

hi there..im new in vb.net..actually i want to upload a pic(browse for pic) into my form...but then,i dont see any openfiledialog n picturebox in my toolbox to be dragged in..pls help me asap..tq..

zumanequeen
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

No way...
Looking carefully on your toolbox.
See an attachment

Attachments DW.JPG 58.58KB
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

thx for your reply..i do know its quite strange but then i still dont see it even the "choose item" i tick all the opendialogfile n picture box...tq

zumanequeen
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You