I have to upload a image file to a server,I have used okhttp multipart upload request to send the request,I have tested the upload in lan using php server and it works perfectly in lan.
But when the php code is hosted in web it does not work.It gives this error in the app
B4X:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>GET to /photo_admin/mobile_api.php not supported.<br />
</p>
<p>Additionally, a 501 Method Not Implemented
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
Method Not Implemented
So I thought there is some server configuration issue and tested the same request using postman in my laptop and the file was uploaded perfectly..I Am totally confused why this is not working in App in web (but works on lan)
B4X:
<p>GET to /photo_admin/mobile_api.php not supported.<br />
But this line here shows its a get request..but multipartpost is a post request Why this happens...!
Dim files As List
files.Initialize
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "pdf"
fd.Dir = File.DirAssets
fd.FileName = "schadensanzeige.pdf"
fd.ContentType = "application/pdf"
files.Add(fd)
Dim job As HttpJob
job.Initialize("Upload",Me)
job.PostMultipart("http://basic4android.de/?varA=16",CreateMap("action":"panne","knr":7,files)
This IS is Post-Request.
But the value varA is given via GET and "action" and "knr" is given inside the post-payload as POST values.
One is data from emulator (This one does not works),And the other one is from postman(This one works).
Both data fetched by wireshark,I think the data looks same ..
I think its some issue related to our upload because I have test it with native iOS test app and uploading is working good.
So browser and native iOS upload is working good.I haven't test native java android
To check whether the file is uploaded you can go to http://arunneeraj.com/uploads/
The link lists all the file that are uploaded.
Once again this is the error am getting
B4X:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>GET to /upload_demo.php not supported.<br />
</p>
<p>Additionally, a 501 Method Not Implemented
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>