0

Good day stack overflow,

I am trying to save pictures in my mysql database, i think i will use BLOB correct?

I am planning to update my mysql database that is already hosted online to support uploading and displaying pictures in my project in vb.net,

I know the easiest way to do saving picture in mysql database is by saving the picture in a directory and putting the path only in the database, but how about for online database that is hosted in the internet and does not have a working directory? I mean just the database itself?

How can i optimized the time access for the picture to load?

1

1 Answer 1

0
 Protected Sub UpLoadThisFile(ByVal upload As FileUpload)
    If UpL1.HasFile Then
        Dim fileName As String = Path.GetFileName(UpL1.PostedFile.FileName)
        UpL1.PostedFile.SaveAs(Server.MapPath("~/AltImg2/") + fileName)
        UpImag.ImageUrl = ("~/AltImg2/") + fileName
        T8.Text = ("~/AltImg2/") + fileName
    Else
        T8.Text = "~/NOPic/noimage.jpg"
    End If
End Sub

 Protected Sub CheckImag()
    If UpL1.HasFile Then
        Dim ValidatFileTy As String() = {"bmb", "gif", "png", "jpg", "jpeg"}
        Dim Ext As String = System.IO.Path.GetExtension(UpL1.PostedFile.FileName)
        Dim isValidFile As Boolean = False
        For i As Integer = 0 To ValidatFileTy.Length - 1
            If Ext = "." & ValidatFileTy(i) Then
                isValidFile = True
            End If
        Next
        If Not isValidFile Then
            MsgLbl.Visible = True
            MsgLbl.ForeColor = Drawing.Color.Red
            MsgLbl.Text = String.Join(",", ValidatFileTy)
            Exit Sub
        Else
            UpLoadThisFile(UpL1)
        End If
    Else
        UpLoadThisFile(UpL1)
    End If
End Sub

and in button

 Protected Sub BTAddNew_Click(sender As Object, e As EventArgs) Handles BTAddNew.Click
    Try
        CheckImag()
        Insert()
        Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

but how about for online database that is hosted in the internet and does not have a working directory? yes you must use ~ ("~/AltImg2/").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.