B4J Question FTP Server and Client - error file upload

Roberto P.

Well-Known Member
Licensed User
Longtime User
I made an example FTP server and client to try sending files on my local pc, but I have problems. Can anyone help me understand where the error is.
thank you

server side:
Sub AppStart (Args() As String)
    server.Initialize(Me, "FTPServer")
    server.SetPorts(51041, 51042, 51142)
    server.AddUser("Test", "test")
    'server.AddUser("anonymous", "") 'anonymous access
    'server.ForcedServerIp = "127.0.0.1" 'local access
    server.BaseDir = "c:\temp\ftp"
    server.Start
    server.ForcedServerIp = "127.0.0.1"
    StartMessageLoop
End Sub

Sub FTPServer_StateChanged
    Log($"Number of clients: ${server.NumberOfClients}"$)
End Sub


client SIDE:
Private Sub startftp
    
    mFtp.Initialize("", "127.0.0.1" , 51041, "Test", "test")
    'mFtp.Initialize("", "ftp.anse2000.it" , 21, "c1422", "c1422nI4ta2")
    
    Log( "isinizialized " & mFtp.IsInitialized)
    'Dim sf_send As Object         = mFtp.SendCommand("MKD", "/somefolder/newfolder")
    
    '"C:\B4J\works\B4JAnse2000\Objects\folderFiles"
    
    Dim sf As Object         = mFtp.UploadFile(File.DirApp, "c1422_ordfor.zip", False, "/c1422_ordfor.zip")
    
    Log("start upload ")
        
    Wait For (sf) ftp_UploadCompleted (ServerPath As String, Success As Boolean)
    
    Log("ServerPath = " & ServerPath)
    
    If Success Then
        Log("file was uploaded successfully")
    Else
        Log("Error uploading file")
    End If
    
    mFtp.Close
    
End Sub


 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Make sure to set the client PassiveMode to True.


yes

B4X:
    mFtp.Initialize("", "localhost" , 21, "Test", "test")
    mFtp.PassiveMode = True



and this the result

 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Have you tried to connect with an FTP Client like Filezilla?
Are you running server and client in the same computer?
Not sure if you should start the server in 127.0.0.0, probably it should it be in 192.168.x.x?
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
[SOLVED]

I used this params:

mFtp.PassiveMode = True
mFtp.UseSSL = False
mFtp.UseSSLExplicit = False

thank
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…