Hola, tengo este código para subir un archivo en ftp.
B4X:
Dim ftp As FTP
ftp.Initialize("ftp","SERVIDOR","21","USUARIO", "CONTRASEÑA")
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/")
end sub
Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
If Success = True Then
Msgbox("ok","")
Else
Msgbox("error","")
End If
End Sub
Se demora un poco el mensaje, pero no realiza la acción, sale el error.
y este otro por HttpJob
B4X:
Dim GrbFir As HttpJob
sub boton_click
GrbFir.initialize("GrbFir", Me)
GrbFir.PostFile("www.ruta", File.DirRootExternal, "sign.png")
end sub
Dim ftp As FTP
ftp.Initialize("ftp","SERVIDOR","21","USUARIO", "CONTRASEÑA")
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/")
ftp.PassiveMode = True
end sub
Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
If Success = True Then
Msgbox("ok","")
Else
Msgbox("error","")
End If
End Sub
Se demora como un minuto para aparecer el mensaje de error.
No me funciono
Te falta el nombre de imagen que va a quedar en el servidor.
B4X:
Dim ftp As FTP
ftp.Initialize("ftp","SERVIDOR","21","USUARIO", "CONTRASEÑA")
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/sign.png")
ftp.PassiveMode = True
end sub
Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
If Success = True Then
Msgbox("ok","")
Else
Msgbox("error","")
End If
End Sub
Dim ftp As FTP
ftp.Initialize("ftp","SERVIDOR","21","USUARIO", "CONTRASEÑA")
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/")
ftp.PassiveMode = True
end sub
Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
If Success = True Then
Msgbox("ok","")
Else
Msgbox("error","")
End If
End Sub
Se demora como un minuto para aparecer el mensaje de error.
Te falta el nombre de imagen que va a quedar en el servidor.
B4X:
Dim ftp As FTP
ftp.Initialize("ftp","SERVIDOR","21","USUARIO", "CONTRASEÑA")
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/sign.png")
ftp.PassiveMode = True
end sub
Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
If Success = True Then
Msgbox("ok","")
Else
Msgbox("error","")
End If
End Sub
Realice exacto lo que esta, la imagen existe en el dispositivo. Al momento de hacer click se demora mucho, y después de un minuto me sale el mensaje de error
Prueba con esto, si no te funciona es problema de acceso al servidor.
B4X:
Sub Process_Globals
Dim FTP As FTP
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
FTP.Initialize("FTP", "ftp.example.com", 21, "user", "password")
End Sub
B4X:
Sub boton_Click
FTP.UploadFile(File.DirRootExternal, "image.png", False, "/public_html/ala/image.png")
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)
If Success = True Then
Msgbox(ServerPath & ", Success=" & Success,"")
Else
Msgbox("Error "&LastException.Message,"")
End If
End Sub
Prueba con esto, si no te funciona es problema de acceso al servidor.
B4X:
Sub Process_Globals
Dim FTP As FTP
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
FTP.Initialize("FTP", "ftp.example.com", 21, "user", "password")
End Sub
B4X:
Sub boton_Click
FTP.UploadFile(File.DirRootExternal, "image.png", False, "/public_html/ala/image.png")
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)
If Success = True Then
Msgbox(ServerPath & ", Success=" & Success,"")
Else
Msgbox("Error "&LastException.Message,"")
End If
End Sub
Sub Process_Globals
Dim FTP As FTP
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
FTP.Initialize("FTP", "ftp.example.com", 21, "user", "password")
FTP.PassiveMode = True
End Sub
B4X:
sub boton_click
FTP.UploadFile(File.DirRootExternal, "sign.png", False, "public_html/sign.png")
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)
If Success = True Then
Msgbox(ServerPath & ", Success subio=" & Success,"")
Else
Msgbox("Error "&LastException.Message,"")
End If
End Sub
Pero al abrirlo del servidor, me sale imagen no disponible. Incluso subir un archivo de .text
pero si lo bajo me funciona, bueno por en mientra esta todo bien. Gracias
Es que es lógico que te siga dando error aun con el PASIVE MODE.
Se que ya lo has solucionado.. pero creo que no te has dado cuenta de tu error..
Revisa esto que has publicado
B4X:
sub boton_click
ftp.UploadFile(File.DirRootExternal, "sign.png",False,"/public_html/ala/")
ftp.PassiveMode = True
end sub
Primero pones a subir el archivo y luego pretendes setearle el modo PASIVO... es a la inversa.. debes primero setear los parametros y luego decirle que suba el archivo..
Hola, disculpen que reviva el POST, pero por seguridad sería correcto hacerlo mediante FTP? o podría enviarse por usando un archivo PHP de por medio?
Yo lo he hecho usando AppInventor y PHP, pero no sé todavía como hacerlo aquí, o bueno en todo caso el compilar la app con Release (Obfuscated) se compila sin opción a descompilar el código facilmente? Ya que el dejar datos del servidor ftp, podría dejar apertura para ataques por allí