Sign in to follow this  
Followers 0
michaelslamet

Get list of file from a webserver

3 posts in this topic

I know how to read a list of files on specific folder on a local/network drive and put it in a array,

but how to do the same on a specific folder on a webserver?

PS: doesn't want to open any browser/window to do that

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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
1 person likes this

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

Share this post


Link to post
Share on other sites

Kylomas, thanks a lot :)

I'm going to see that, _FTP_ListToArray seems promising.

Thanks again! :thumbsup:

Share this post


Link to post
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
Sign in to follow this  
Followers 0