Browse a file and then upload it to mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vanita01
    New Member
    • Feb 2008
    • 3

    Browse a file and then upload it to mysql

    Hi

    Can anyone please help me. I am trying to browse for a file. I would like the file path name to be shown on a text box. Using the upload button I would then like to save the file on mysql. is is the code I have don so far.

    [CODE=vb]Private Function LoadFile(sFile As String) As Boolean
    Dim filenum

    Text2.Tag = sFile

    ' Make sure a file is specified.
    If sFile = "" Then
    LoadFile = False
    Exit Function
    End If

    ' Make sure the file exists before trying to open it.
    If Dir(sFile) = "" Then
    LoadFile = False
    Exit Function
    End If

    ' Read the collection from a text file.
    ' Get a free file number
    filenum = FreeFile

    ' Open sfile for input
    Open sFile For Input As filenum
    On Error Resume Next
    ' Read the contents of the file into TextBox1
    Text2.Text = Input(LOF(filen um), filenum)
    If Err Then
    Text2.Text = "Error Loading File. Invalid Format"
    Close filenum
    LoadFile = False
    End If
    ' Close the file
    Close filenum

    LoadFile = True
    End Function


    Private Sub Command10_Click ()
    'Opens a Treeview control that displays the directories in a computer
    Command1.Visibl e = True

    Dim lpIDList As Long
    Dim sBuffer As String
    Dim szTitle As String
    Dim tBrowseInfo As BrowseInfo

    szTitle = "File to Upload:"
    With tBrowseInfo
    .hWndOwner = Me.hwnd
    .lpszTitle = lstrcat(szTitle , "")
    .ulFlags = BIF_RETURNONLYF SDIRS + BIF_DONTGOBELOW DOMAIN
    End With

    lpIDList = SHBrowseForFold er(tBrowseInfo)

    If (lpIDList) Then
    sBuffer = Space(MAX_PATH)
    SHGetPathFromID List lpIDList, sBuffer
    sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)

    'Text1.Text = sBuffer
    txtFields(14).T ext = sBuffer
    MsgBox sBuffer
    End If


    End Sub[/CODE]
    Last edited by Killer42; Feb 15 '08, 01:59 AM. Reason: Added CODE=vb tag
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    What is the problem with the code ?

    Why are you reading the contest of the file ?

    Comment

    Working...