Android Question Request URI Too Long

ilan

Expert
Licensed User
Longtime User
hi

i am updating a mysql db using PHP Get request. i am using httpjob.Download2 with key/value parameters. everything work fine but if i want to upload an image converted to base64 i am getting this error:

Copying updated assets files (46)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
15 ms
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: Request-URI Too Long, Response: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Long</title>
</head><body>
<h1>Request-URI Too Long</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
<p>Additionally, a 414 Request-URI Too Long
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
error uploading user

i need to mention that i cannot use B4j Server tool because this is a shared hosting so i have to use PHP and i also DON'T want to use FTP and upload the image. i know it is a better approach but because it is a small image (just an avatar of around 10kb) i would like to stay with sql db only and no ftp upload.
what could i do to archive it? it seems like there is a limit of the length of the url that my hosting allows. is there another way the get around this?
i was thinking of using BLOB instead and upload the image as a byte array using POST request. what do you think?
 

DonManfred

Expert
Licensed User
Longtime User
You should use PostMultipart and handle the fileupload correctly in PHP.
You are not limited to any amount of data using POST-Requests

A GET-Request can only have a limited amount of data.

If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path. However, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the header and not in the URL.
 
Upvote 0
Top