Android Question Upload file to www

JamesGreaves

Active Member
Licensed User
Downloading is really simple and works great, but I cannot find a simple way to upload a file.
Is there one?

B4X:
' UPLOADING
    Dim Job As HttpJob 
    Job.Initialize( "j", Me)
    Job.Download("http://www.something.xx/" & Filename)
.
.
.
    Sub JobDone(job As HttpJob)
                 
        If job.Success Then
            Dim RootFolder As String
            RootFolder=File.DirRootExternal
            Dim out As OutputStream = File.OpenOutput(RootFolder,  Filename,  False)
            File.Copy2( job.GetInputStream, out)
            out.Close 
        Else
            Log("Error: " & job.ErrorMessage)
        End If
        job.Release
          
    End Sub


' DOWNLOADING
    Dim Job As HttpJob 
    Job.Initialize( "j", Me)
    Job.Upload(Filename, "http://www.something.xx/")
 

DonManfred

Expert
Licensed User
Longtime User
To upload files to your webserver usually ftp is used.

You can use httputils if your server expect files and a php-script copies the file to the right place.
I mean you have a php-script running which will receive fileuploads.
 
Upvote 0

JamesGreaves

Active Member
Licensed User
Thanks for the replies.
If I use Filezilla or something similar, it works without having to set up anything on the server side.
I can do this in VB, so can't we create a way to do it in B4A?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

JamesGreaves

Active Member
Licensed User
OK, so I can use the FTP object for simple file upload tasks? Thanks I didn't see that before.

Thanks for all your work Erel, and especially B4A, I am excited about programming again!!
 
Upvote 0

JamesGreaves

Active Member
Licensed User
Thanks DonManfred, I appreciate your input very much.
I see there is also a NET library, should I not perhaps use that instead? Or is there a difference?
 
Upvote 0
Top