Error Codes Wiki

Multipart Form Data Errors — File Upload HTTP Request Failures

Warning4xx client error

Overview

Fix multipart/form-data upload errors including boundary parsing failures, size limit exceeded, and content-type mismatches in HTTP file uploads.

Key Details

  • Multipart form data is the standard encoding for HTTP file uploads using Content-Type: multipart/form-data
  • Each part is separated by a boundary string specified in the Content-Type header
  • Servers impose size limits on individual files and total request body size
  • Missing or malformed boundary strings cause 400 Bad Request errors
  • Incorrect Content-Type header (e.g., application/json instead of multipart/form-data) causes parsing failures

Common Causes

  • Content-Type header missing the boundary parameter required for multipart parsing
  • Request body exceeding server-configured maximum size (Nginx: client_max_body_size, Apache: LimitRequestBody)
  • Client manually setting Content-Type without letting the HTTP library auto-generate the boundary
  • File field name in the request not matching the expected field name on the server

Steps

  1. 1Do not manually set the Content-Type header — let your HTTP client library generate it with the correct boundary
  2. 2Increase server upload limits: Nginx 'client_max_body_size 50m;' or Apache 'LimitRequestBody 52428800'
  3. 3Verify the form field name matches the server expectation (e.g., 'file' vs 'upload' vs 'attachment')
  4. 4Check for proxy/CDN upload size limits (Cloudflare free tier limits uploads to 100MB)
  5. 5Use chunked uploads for large files to avoid timeout and memory issues

Tags

multipartfile-uploadform-databoundarycontent-type

More in 4xx Client Error

Frequently Asked Questions

The multipart boundary must be included in the Content-Type header and match the delimiters in the body. HTTP libraries like fetch, axios, and curl auto-generate this when you use FormData.