Hi all,
I'm trying to find an 'elegant' way to do this action.
But I'm stuck so far.
Maybe someone can see the problem that I have.
Okay, so here are the codes:
So, by pushing btSend button, the image file will go to a ftp folder public_html/test or test2 depending on
the string of the value Input1/Input2.
Hope it's clear enough to understand the problem.
Thanks for now.
I'm trying to find an 'elegant' way to do this action.
But I'm stuck so far.
Maybe someone can see the problem that I have.
Okay, so here are the codes:
B4X:
Sub Process_Globals
Dim result As String
result = ""
Dim FTP As FTP
Dim Input1, Input2, SP As String
Dim FP0, FP1 As String
Dim Host, User, Password As String
Host = "www.com"
User = "1234"
Password = "1234"
Dim Port As Int
Dim FPIndex As Int
Dim FP(2) As String
FP0 = "public_html/test1/"
FP1 = "public_html/test2/"
End Sub
B4X:
Sub Globals
Dim LbAuto, LbMotor As Label
Dim LbAutoInput, LbMotorInput As Label
Dim btSend As Button
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("preview.bal")
FTPConnect
FTP.Initialize("FTP", Host, 21, User, Password)
End Sub
B4X:
Sub Activity_Resume
LbAuto.Text = "" & Selection ------> Selection : values of a spinner(example: Alfa Romeo, BMW, etc)
End Sub
B4X:
Sub Activity_Pause (UserClosed As Boolean)
LbAuto.Text = "" & Selection
FTP.Close
End Sub
B4X:
Sub FTPConnect
End Sub
B4X:
Sub btSend_Click
Input1 = LbAuto.Text
Input2 = LbMotor.Text
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal & "/Test/" , Input1 & Input2 & ".jpg", False)
bmp.WriteToStream(Out, 100, "JPEG")
Out.Close
StartActivity("menu2")
If Input1 = "BMW" Then -------> This is what I came up with
FP0 = True
End If
FTP.UploadFile(File.DirRootExternal & "/Test/", Input1 & Input2 & ".jpg", False, FP(FPIndex) & Input1 & Input2 & ".jpg")
End Sub
B4X:
Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
SP = FP(FPIndex) & Round(TotalUploaded / 1000) & "KB"
If Total > 0 Then SP = SP & " out of " & Round(Total / 1000) & "KB"
Log(SP)
End Sub
B4X:
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
So, by pushing btSend button, the image file will go to a ftp folder public_html/test or test2 depending on
the string of the value Input1/Input2.
Hope it's clear enough to understand the problem.
Thanks for now.
Last edited: