Android Question POST action and FileData type...

danoveb

Member
Licensed User
Longtime User
Hi!

What I actually are trying to solve is to send a file to a server. I have find some threads about it, but then I got a new problem with "FileData" type. I get
"Unknown Type: filedata
Are you missing a library reference?"

I have tried to check all Libraries in the Libraries Manager but still same error. Are there som way to find out what Library that type are to be find, or can somebody tell me what Library I need to download?


This is the post action i want to execute with my code:

<form method="POST" action="" enctype="multipart/form-data">
<input type="file" name="update">
<input type="submit" value="Update">
</form>

I have tried with HttpJob.PostFile function, but that didn't work.

Then I found this thread:
https://www.b4x.com/android/forum/threads/android-http-multipart-requests.8411/
But then I got problem with the "FileData" type.
 

DonManfred

Expert
Licensed User
Longtime User
1. See the first note in the link you found!
For new projects it is recommended to use OkHttpUtils2: https://www.b4x.com/android/forum/threads/54723/#content
2. Switch from http and httputils to https://www.b4x.com/android/forum/threads/okhttp-replaces-the-http-library.54723/#content
3. Code to upload using okhttputils2
B4X:
Dim j As HttpJob
j.Initialize("j", Me)
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "update"
fd.Dir = File.DirAssets
fd.FileName = "image.png"
fd.ContentType = "image/png"
j.PostMultipart("http://...", CreateMap("param1": "value1"), Array(fd))
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…