Hi,
i have problem on inserting multiple images.
i found in internet, many examples are regarding insert only one image.
but now i want it to have multiple uploaded images that we can delete and view it first before we save it on database. how to store the images uploaded? are in dataset@something like that?

all your replies are welcomed.
TQ

Here some of the code

this is btnBrowse for browsing images( browse only one at a time)
i using a panel (panel1), a picture box (PictureBox1
) ,label (Label6) and button(btnBrowse2)

Private Sub btnBrowse2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse2.Click

        ' Use an OpenFileDialog to enable the user to find an image to save to the 
        ' database. Provide a pipe-delimited set of pipe-delimited pairs of file 
        ' types that will appear in the dialog. Set the FilterIndex to the default 
        ' file type.
        With OpenFileDialog1
            .InitialDirectory = "C:\"
            .Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
            .FilterIndex = 2
        End With

        ' When the user clicks the Open button (DialogResult.OK is the only option;
        ' there is not DialogResult.Open), display the image centered in the 
        ' PictureBox and display the full path of the image.
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            With PictureBox1
                .Image = Image.FromFile(OpenFileDialog1.FileName)
                .SizeMode = PictureBoxSizeMode.CenterImage
                ' .BorderStyle = BorderStyle.Fixed3D
            End With
            '   lblFilePath.Text = OpenFileDialog1.FileName
            Label6.Text = OpenFileDialog1.FileName

        End If
    End Sub

Then i use another button > btnSave to store the image browsed into a datatable@dataset@somewhere in datagrid(but not in database. store in database i want to use another save button.)

the used i do like this because i want to view the images uploaded, also i want to add another images, then i also can delete the images before i finalized to store all of it in a database.

hope can helps me:)

first, you have to consider if the control you would be using for image preview to know if it can accept your requirement. The PictureBox is the best for such purpose but am not sure it can accept more than one image at a time. Another way is if you can have multiple PictureBoxes and have them previewed before saving all into the database.

first, you have to consider if the control you would be using for image preview to know if it can accept your requirement. The PictureBox is the best for such purpose but am not sure it can accept more than one image at a time. Another way is if you can have multiple PictureBoxes and have them previewed before saving all into the database.

yes i have tried using this code, can insert multiple images in picturebox that i create each time to insert each image.

Dim ofd As New OpenFileDialog
        With ofd
            .Multiselect = True '// allows to MultiSelect Images/Files.
            .Title = "Please select one or more images to load..." '// Title for the OpenFileDialog.
            ''  // Filters for Images/Files.
            .Filter = "All Images (*.jpg,*.jpeg,*.gif,*.png,*.bmp)|*.jpg;*.jpeg;*.gif;*.png;*.bmp|" _
                     & "JPEG Images (*.jpg,*.jpeg)|*.jpg;*.jpeg|GIF Images (*.gif)|*.gif|PNG Images (*.png)|*.png|Bitmaps (*.bmp)|*.bmp"
            If .ShowDialog = DialogResult.OK Then
                Panel1.Controls.Clear() '// Clear Previous PictureBox(es).
                Dim iX As Integer = 0 '// Location.X for each PictureBox.
                Dim iPbWidth As Integer = 175, iPbHeight As Integer = 175 '// Preset Width and Height.
                For Each selectedImage As String In .FileNames '// Loop thru all Selected Images.
                    Dim PictureBox1 As New PictureBox '// Create new PictureBox.
                    PictureBox1.Image = Image.FromFile(selectedImage) '// Set Image to new PictureBox.
                    PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize '// Set .SizeMode to determine if PictureBox needs to display as "Zoom" or "CenterImage".
                    If PictureBox1.Width > iPbWidth OrElse PictureBox1.Height > iPbHeight Then '// if image loaded is greater in width/height than the Preset Sizes...
                        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom '// Zoom image.
                    Else
                        PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage '// Center image.
                    End If
                    '   PictureBox1.Size = New Size(iPbWidth, iPbHeight) '// set preset Size for PictureBox.
                    PictureBox1.Location = New Point(iX, 0) '// add Locatio6n.
                    '     pb.BorderStyle = BorderStyle.FixedSingle '// set Border if needed to define each image as it's own.
                    Panel1.Controls.Add(PictureBox1) '// Add PictureBox to Panel.
                    iX += PictureBox1.Width + 5 '// set new Location.X for the next PictureBox.
                Next
            End If
        End With

but i dont know how to delete the images (selected images) i choose in the pictureboxes

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.