# Can't submit form-data

**URL:** <https://answers.netlify.com/t/cant-submit-form-data/81605>\
**Category:** Support\
**Tags:** deployment\
**Created:** [December 19, 2022, 5:26pm UTC](https://answers.netlify.com/t/cant-submit-form-data/81605 "2022-12-19T17:26:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![isnas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/isnas/32/53974_2.png) [@isnas](https://answers.netlify.com/u/isnas)\
**Post date:** [December 19, 2022, 5:26pm UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/1 "2022-12-19T17:26:42Z")

</div>

I have NextJs app that is hosted on netlify,

On my website i have a form that uses multipart to send text with files

This multi-part data is going to nextjs api and then to my backend, so in the end it looks like so

client → nextjs api route → backend api route

When i’m sending form without files or with files that are less than 4 mb everything works as expected,  
but when i’m trying to send files that are larger than 4mb, it suddenly fails with following errors

```auto
SyntaxError: Unexpected token '<', "<HTML>
<HE"... is not valid JSON

```

if i go to network and look there, then it says “Sever closed connection”

or

```auto
SyntaxError: Unexpected end of JSON input

```

Which has empty response on network tab

What am i doing wrong? i’ve heard about 4mb limit in nextjs, but i’ve changed it like so

```auto
export const config = {
  api: {
    bodyParser: false,
    responseLimit: false,
  },
};

```

And also one important note, if i build my app and start it locally, everything works as expected and i’m able to send files larger than 4 mb

---

<div class="post-metadata">

**Author:** ![clarnx](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/clarnx/32/40777_2.png) [@clarnx](https://answers.netlify.com/u/clarnx)\
**Post date:** [December 19, 2022, 10:02pm UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/2 "2022-12-19T22:02:49Z")

</div>

Hi @isnas, welcome and thanks for the post.

Note that Netlify forms does have limitations. Kindly check the Neflify documentation link below for more information about limitations.

> **[Forms setup](https://docs.netlify.com/forms/setup/#limitations)**
>
> Use built-in form handling to simplify adding and managing forms for your project. There’s no need to make an API call or include extra form handling code.

You can also check the Netlify blog link below on how to properly add Netlify forms to your Next.js site.

> **[Add a Netlify-powered contact form to your Next.js site](https://www.netlify.com/blog/2020/05/26/add-a-netlify-powered-contact-form-to-your-next-js-site/)**
>
> Accepting submissions to forms with Netlify and Next.js is straightforward, with just a few easy steps!

Thanks.

---

<div class="post-metadata">

**Author:** ![isnas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/isnas/32/53974_2.png) [@isnas](https://answers.netlify.com/u/isnas)\
**Post date:** [December 19, 2022, 10:07pm UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/3 "2022-12-19T22:07:57Z")

</div>

If i understand correctly this only applies to forms that use `data-netlify=true` which i don’t use, i have a regular form that sends data to NextJS backend api which then gets redirected to my backend

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [December 20, 2022, 1:10am UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/4 "2022-12-20T01:10:58Z")

</div>

Hi, @isnas. The Next.js API route is using Netlify Functions which are in turn using AWS Lambda.

Lambda itself has a limit on POST size as documented here:

> **[Lambda quotas - AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)**
>
> Maximum sizes, limits, and quotas for Lambda functions and API requests.

There it says this:

> | [Invocation payload](https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html) (request and response) | 6 MB each for request and response (synchronous) |
> | --- | --- |

The files are also likely being base64 encoded by the browser before being sent which also makes them larger. This is why a file smaller than 6 MB is hitting the limit (because it is over 6 MB after the base64 encoding).

This is my best guess as to why the large file uploads are failing.

The primary solution for this is to not use AWS Lambda for the form. If Lambda is used, this limitation will always exist.

---

<div class="post-metadata">

**Author:** ![isnas](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/isnas/32/53974_2.png) [@isnas](https://answers.netlify.com/u/isnas)\
**Post date:** [December 20, 2022, 9:32am UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/5 "2022-12-20T09:32:50Z")

</div>

Thanks, i knew something was not working on netlify side or i was hitting the limit, but wasn’t able to find what exactly it was, now it all makes sense, so i guess if i want to handle uploads up to 20MB i have to use my backend route directly from client and there is no other way for this to work?

---

<div class="post-metadata">

**Author:** ![audrey](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/audrey/32/24328_2.png) [@audrey](https://answers.netlify.com/u/audrey)\
**Post date:** [December 20, 2022, 7:32pm UTC](https://answers.netlify.com/t/cant-submit-form-data/81605/6 "2022-12-20T19:32:25Z")

</div>

Hi @isnas , sorry to say there isn’t a way to upload up to 20MB using form submissions as Luke mentioned, the Next.js API route is using Netlify Functions which are in turn using AWS Lambda which has the 6MB limitation.
