L lip Active Member Licensed User Longtime User Mar 17, 2015 #1 I am using PostString in B4A to send JSON Strings to servers. After some issues with url encoding this is all working well. I am now trying to upload bitmap files from the tablet (stored in File.DirRootExternal) to the servers. So far I have been using PostFile ie Job1.PostFile("http://.....aspx",File.DirRootExternal,"file.bmp") We can see something hitting the pages but struggling to interpret it at the server end. I am working with two different developers; one using vb.net and the other .asp. Both are having the same issues. Should I forget PostFile and use the http.MultiPartPost...I have read a forum thread and it looks like I might get a bit more control like attaching Key/Value pairs to attach some information about the files, but it also looks far more complicated than Postfile?
I am using PostString in B4A to send JSON Strings to servers. After some issues with url encoding this is all working well. I am now trying to upload bitmap files from the tablet (stored in File.DirRootExternal) to the servers. So far I have been using PostFile ie Job1.PostFile("http://.....aspx",File.DirRootExternal,"file.bmp") We can see something hitting the pages but struggling to interpret it at the server end. I am working with two different developers; one using vb.net and the other .asp. Both are having the same issues. Should I forget PostFile and use the http.MultiPartPost...I have read a forum thread and it looks like I might get a bit more control like attaching Key/Value pairs to attach some information about the files, but it also looks far more complicated than Postfile?
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2015 #2 It really depends on what the server expects. PostFile create a POST request with the file data as the request payload. If your server is configured to handle it then it is indeed very simple. You can use standard url parameters with PostFile. If your server only accepts multipart requests then you need to follow this link: https://www.b4x.com/android/forum/threads/8411 Upvote 0
It really depends on what the server expects. PostFile create a POST request with the file data as the request payload. If your server is configured to handle it then it is indeed very simple. You can use standard url parameters with PostFile. If your server only accepts multipart requests then you need to follow this link: https://www.b4x.com/android/forum/threads/8411
L lip Active Member Licensed User Longtime User Mar 17, 2015 #3 Thanks for your help. I have implemented the Multipart version but get a similar error to one reported by another user on the forum:- Anywheresoftware.b4a.http.Http.ClientWrapper$HttpResponceWrapper@...... Any obvious places to look...? Upvote 0
Thanks for your help. I have implemented the Multipart version but get a similar error to one reported by another user on the forum:- Anywheresoftware.b4a.http.Http.ClientWrapper$HttpResponceWrapper@...... Any obvious places to look...?
Erel B4X founder Staff member Licensed User Longtime User Mar 18, 2015 #4 Can you post the full error message (in debug mode)? Upvote 0
fixit30 Active Member Licensed User Longtime User Mar 18, 2015 #5 Hi Lip. I upload files to my asp.net webserver using httputils PostBytes method. On the Server Side the Byte Array can then be handled with the following code and either saved to a database or the file system as required. Code: Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim data() As Byte data = Request.BinaryRead(Request.TotalBytes) IO.File.WriteAllBytes("C:\PictureName.jpg", data) End Sub Upvote 0
Hi Lip. I upload files to my asp.net webserver using httputils PostBytes method. On the Server Side the Byte Array can then be handled with the following code and either saved to a database or the file system as required. Code: Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim data() As Byte data = Request.BinaryRead(Request.TotalBytes) IO.File.WriteAllBytes("C:\PictureName.jpg", data) End Sub