B4J Question Upload jpg/mp4 to Websocket fileupload

Nizze

Active Member
Licensed User
Longtime User
Hi

I use Erels example for B4J for http upload
I use this code for uploading a jpg that i found in the forum here to upload to server with a PHP script.
It works on a server with apache

No i want to have it running with B4J

this is the code from the android client:

B4X:
Sub PhotoUpload(filname As String)
    Log("PhotoUpload " & filname)

    PostPath = "http://www.xxxxx.se:81/websocket_with_fileupload/index.html"
    Dim j As HttpJob
    Dim img As String = filname '"1.jpg"
    j.Initialize("", Me)
    Dim mp As MultipartFileData
    mp.Initialize
    mp.Dir = rp.GetSafeDirDefaultExternal("")
    mp.FileName = img
    mp.KeyName = "file"
    mp.ContentType = "image/jpg"
    j.PostMultipart(PostPath, Null, Array(mp))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log("- - - - - - - - - - - - - ")
        Log(j.GetString)
        If img = j.GetString Then
            ToastMessageShow("Kort upladdat.", False)
        Else
            ToastMessageShow("Fel vid uppladdning", False)
        End If
    End If
    j.Release
    
End Sub

and the log from the server :


What can i do to get upload to work ?
And if i try to upload an .Mp4 file , i dont get anything in the log
eveen if i change mp.ContentType = "image/jpg" to mp.ContentType = "video/mp4"

Br
Nizze
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Nizze

Active Member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…