Android Question FTP UploadFile

Hello,

I'm trying to create an app for sending pictures from the device to a PC with FileZilla.
I think that my problem is that I dont actually understand what the full path is in the UploadFile function, because the client connects to the server but cannot upload anything (success is false always) and everytime I try to upload my FileZilla log says this:

(000050)03/09/2021 13:33:37 - prueba (xxx.xxx.xxx.xxx)> TYPE I
(000050)03/09/2021 13:33:37 - prueba (xxx.xxx.xxx.xxx)> 200 Type set to I

Supposedly the user autoconnects to a certain folder that I have created in the desktop. What should this path be?

B4X:
Dim sf As Object = FTP.UploadFile(sDir, foto, False, "/filezilla/sdcard/" & foto)

Thanks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 1
Depends on the path you set as homedir for the specific ftp user. Usually the startpath is /
I have already tried every possible path and is still not working. Everytime I use the UploadFile function I get this message in the Filezilla log:

(000050)03/09/2021 13:33:37 - prueba (xxx.xxx.xxx.xxx)> TYPE I
(000050)03/09/2021 13:33:37 - prueba (xxx.xxx.xxx.xxx)> 200 Type set to I

Any idea why is this happening?
 
Upvote 0
Hm okay. But why I get that log everytime I use UploadFile?

I have a button that calls this sub

B4X:
Private Sub btnUpload_Click
    Dim sf As Object = FTP.UploadFile(sDir, foto, False, "/filezilla/sdcard/" & foto)
    Wait For (sf) FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        ToastMessageShow("Uploaded con éxito", True)
        Else
        ToastMessageShow("No uploadeado", True)
    End If
End Sub

and everytime I click it shows that message in the log :/
 
Upvote 0
Hello again,

I've made some changes but the app still doesn't upload any file, even though it shows the SET TYPE TO I in the FileZilla log.

I'm attaching the project so feel free to take a look and test, thank you in advance
 

Attachments

  • FTP.zip
    10.3 KB · Views: 254
Upvote 0

josejad

Expert
Licensed User
Longtime User
If you put some logs to see what's happening, you will see you're not getting the path of the image you want to upload.

B4X:
   Dim sf As Object = FTP.UploadFile(sDir, foto, False, "/" & foto)
    Log(sDir)
    Log(foto)

You will see sDir is "/storage/emulated/0/Android/data/b4a.example/files", and obviously your image is not there. You will need the full path to the image.
I see you're using this example to get info of the choosen image, but you get just the name, not the path.

Not sure if this post could help you.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Don't waste your time with activities. Switch to B4XPages. I'm familiar with B4A and know what I'm talking about.
2. Don't try to get the full path. It will not work.
3. See TextEditor example: https://www.b4x.com/android/forum/t...-save-and-load-external-files.132731/#content
Especially see the Load method. It does everything that you need. Just change the mime type.

B4X:
FTP.UploadFile(Result.Dir, Result.FileName, False, "/" & Result.RealName)
Make sure that Result.RealName isn't empty. It is possible that it will be empty.
 
Upvote 0
Top