Android Question Problem with the FTP

catyinwong

Active Member
Licensed User
Longtime User
I am tried of trying all the FTP libraries (Both FTP and FTP_Auto) and examples through this forum, with all return the error with the code of "500".. I have also seen that many people encounter different problems but their solutions don't work for me either.. =(

I have tried to connect to the FTP with my computer (using the same network with my phone) and it connects successfully.. Anyway, is there anyone can put up with a successful example that can connect + upload + download from my FTP server.. that's all I need..

Here is the host, username and passwords:
"tt.host22.com"
"a7369129"
"Calix841124"

I will change the password after I have got a successful example. And again, I am so tired of trying the examples in this forum, putting all the info only to see it fail... so pls pls help me to make one that I just have to download and launch to see it works...
 

catyinwong

Active Member
Licensed User
Longtime User
12074563_10153290933009092_4755094145558704332_n.jpg


It is how it looks when I use FTP_Auto.. The error in the log is the same if I use the FTP in Net.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
this works on my device, it is the example from Erel (https://www.b4x.com/android/forum/threads/android-ftp-tutorial.10407/) and uses this lib:https://www.b4x.com/android/forum/threads/new-net-library-android-ftp-smtp-and-pop3.10892/
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim FTP As FTP

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    FTP.Initialize("FTP", "tt.host22.com", 21, "a7369129", "Calix841124")
    FTP.UploadFile(File.DirAssets, "1.txt", True, "1.txt")
    'FTP.DownloadFile("/somefolder/files/1.zip", False, File.DirRootExternal, "1.zip")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    Dim s As String
    s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
    Dim s As String
    s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub
 
Upvote 0

catyinwong

Active Member
Licensed User
Longtime User
this works on my device, it is the example from Erel (https://www.b4x.com/android/forum/threads/android-ftp-tutorial.10407/) and uses this lib:https://www.b4x.com/android/forum/threads/new-net-library-android-ftp-smtp-and-pop3.10892/
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim FTP As FTP

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    FTP.Initialize("FTP", "tt.host22.com", 21, "a7369129", "Calix841124")
    FTP.UploadFile(File.DirAssets, "1.txt", True, "1.txt")
    'FTP.DownloadFile("/somefolder/files/1.zip", False, File.DirRootExternal, "1.zip")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    Dim s As String
    s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
    Dim s As String
    s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub

Have you tried uploading or downloading? Because I don't see any new files on the server.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
I've uploaded a file and only looked to the logs from the code. But now I ve take a look to your server and there is the file called 1.txt ( it is in the root directory where it says: DO_NOT_UPLOAD_HERE....so upload works...and download to. I've downloaded the same file 1.txt from the server:
B4X:
FTP.DownloadFile("1.txt", False, File.DirRootExternal, "1.txt")
 
Upvote 0

catyinwong

Active Member
Licensed User
Longtime User
I've uploaded a file and only looked to the logs from the code. But now I ve take a look to your server and there is the file called 1.txt ( it is in the root directory where it says: DO_NOT_UPLOAD_HERE....so upload works...and download to. I've downloaded the same file 1.txt from the server:
B4X:
FTP.DownloadFile("1.txt", False, File.DirRootExternal, "1.txt")

That's strange.. Now I see the file in the root folder of the FTP.. but mine still doesn't work and comes up with the same error..

B4X:
#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim FTP As FTP
Dim my As Catling
Public cc As ContentChooser
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    FTP.Initialize("FTP", "tt.host22.com", 21, "a7369129", "Calix841124")
 cc.Initialize("ChangeControlImage")
cc.Show("image/*","Please choose an image") '開啟視窗選擇圖片  
    'FTP.DownloadFile("/somefolder/files/1.zip", False, File.DirRootExternal, "1.zip")
End Sub

Sub ChangeControlImage_Result(Success As Boolean, Dir As String, FileName As String)
If Success <> True Then
ToastMessageShow("No Image Selected",False)
Return
End If
    Dim Fullpath As String = my.GetPathFromContentResult(FileName) 'FullPath = 路徑 + 文件名
    FileName = Fullpath.SubString(Fullpath.LastIndexOf("/") + 1) ' FileName = 文件名
    Log(Fullpath)
    Log(FileName)
    FTP.UploadFile("",Fullpath,True, FileName)
    'FTP.UploadFile("/home/a7369129/public_html","",Fullpath)
'If SubExists(Me,Subv) Then CallSub3(Me,Subv,Fullpath,FileName)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    Dim s As String
    s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
    Dim s As String
    s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub

Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub
 
Upvote 0
Top