What is multipart/form-data?
multipart/form-data is a media type commonly used for HTTP form bodies. It packages form fields and file content into parts separated by a boundary declared in Content-Type. The format defines the body representation; resumability requires a separate transfer contract.
How multipart/form-data works
Each part has headers describing its field name and, for a file, possibly a filename and media type. A boundary separates the parts, and the enclosing Content-Type identifies that same boundary. Browser FormData serialization creates the body and header together. Setting a bare Content-Type: multipart/form-data manually can omit the generated boundary and prevent the receiver from parsing the request.
Key facts
- A single multipart form can include several files. That does not mean those files or their internal byte ranges can be resumed independently.
- The filename and part MIME type are supplied by the sender. Validate the file contents and normalize storage names on the receiving side.
- Form encoding does not determine buffering behavior. A server can stream a multipart body or buffer it, depending on its implementation.
When multipart/form-data matters
Use FormData when an endpoint expects a multipart form. Let the browser set Content-Type and its matching boundary, and use the field names defined by the receiving API.