2

I am having an issue, when i send a large size image in base64 (around 20 MB) as a FormData param the AJAX POST request does not work. If it is less than 10 MB, the request FormData params work correctly. Why is it behaving like this?

var formData = new FormData();
formData.append(“base64Image”, “<LARGE SIZE BASE64 STRING>”);
$.ajax({
   url : "/api/extensions",// no i18n
   method : "POST",//no i18n
   processData : false,
   contentType : false,
   data : formData
   ...
});
Thomas Andreè Wang
  • 3,379
  • 6
  • 37
  • 53
Abraham Gnanasingh
  • 837
  • 2
  • 10
  • 31

1 Answers1

0

I believe this is a server issue. Not sure what server you're using but in Payara I think they configure the max allowed upload size like this;

max-post-size-bytes, can be configured also in admin console, setting it to -1 will remove size limits and accept any request

max-form-post-size-bytes this cannot be configured in Admin console, only via asadmin command this is only being applied to requests with content type application/x-www-form-urlencoded, therefore it is ignored for most form file uploads"

from here

EDIT: from other questions I've seen on the internet about this exact issue, there have been dodgy server config/php_ini files that haven't been parsed properly, multiple settings files that you might have to configure, but for struts, could you try and implement the example in this walk through? Also, are you sure your config has 100000000 bytes and not 10000000?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
juju
  • 553
  • 1
  • 4
  • 21
  • I am using Java Struts 2 – Abraham Gnanasingh Apr 23 '20 at 13:03
  • seems like you answer could be this: https://stackoverflow.com/questions/4821334/limit-struts2-file-upload-max-size-without-uploading-the-whole-file#answer-4823524 – juju Apr 23 '20 at 13:06
  • I edited the question with my code. Does it work if I try with application/x-www-form-urlencoded instead of multipart/form-data request? – Abraham Gnanasingh Apr 23 '20 at 18:08
  • Nah multi part should be fine, as far as I know, Ajax doesn't have a limit and neither does formats as I've used them with large files. So it has to be something else – juju Apr 23 '20 at 23:12
  • Have you seen this post? Without seeing server config it's hard to help. https://stackoverflow.com/questions/19225881/not-able-to-upload-large-files – juju Apr 23 '20 at 23:13