Jump to content

Get list of file from a webserver


Go to solution Solved by kylomas,

Recommended Posts

  • Solution

michaelslamet,

This is how I list files from a specific directory at my WEB server...

 

Func display_remote_files()

    $file_count = 0

    GUICtrlSetData($lbl020,'Finding remote files...please wait...')
    GUICtrlSetData($edt010,'')

    Local $server       = '*********************'
    Local $username     = '********'
    Local $pass         = '********'

    Local $Open = _FTP_Open('Samolyk FTP')
    If $open = 0 Then
        l(' FTP Open Error - Error code = ' & @error & _WinAPI_GetLastErrorMessage())
        Exit
    endif

    Local $Conn = _FTP_Connect($Open, $server, $username, $pass)
    If $conn = 0 Then
        l(' FTP Connect Error - Error code = ' & @error & _WinAPI_GetLastErrorMessage())
        exit
    endif

    Local $hfl
    Local $a_files  = _FTP_findfilefirst($conn,"/www/klms/",$hfl)
    If @error = -1 Then
        GUICtrlSetData($lbl020,$file_count & ' files available for download...')
        Return
    endif

    GUICtrlSetData($edt010,$a_files[10] & @crlf, 1)

    $file_count += 1

    While 1
        $a_files = _ftp_findfilenext($hfl)
        If @error = -1 Then
            exitloop
        EndIf
        GUICtrlSetData($edt010,$a_files[10] & @crlf, 1)
        $file_count += 1
    wend

    GUICtrlSetData($lbl020,$file_count & ' file(s) available for download...hit "DOWNLOAD FILES" to start download...')

    _ftp_findfileclose($hfl)

    Local $Ftpc = _FTP_Close($Open)
    If $ftpc = 0 Then
        l(' FTP CLose Error = ' & @error & @LF & _WinAPI_GetLastErrorMessage())
        exit
    EndIf

endfunc

There are other, better FTP* functions that I was unaware of when I wrote this (see Help file).

kylomas

Edit: Obviously this is part of a script so the GUI references and references to function L() don't make sense.  If the FTP functions are not clear I'll post the entire script.

Edit2:  A better example is right in the Help file under _FTP_ListToArray.

 

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...