multipart/form-data
The MIME type for submitting forms containing files, binary data, and mixed content.
What Is This?
The multipart/form-data MIME type is used for HTML form submissions that include files, binary data, or non-ASCII text. Unlike application/x-www-form-urlencoded (which URL-encodes all values), multipart/form-data encodes each form field as a separate part in a multipart message, allowing efficient binary file transfer.
Common Uses
Common Use
HTML forms with file upload <input type='file'> fields
Common Use
REST API endpoints accepting file uploads
Common Use
Email attachments (though with different multipart subtypes)
Common Use
Batch data submission with mixed content types
Examples
Serve files with the multipart/form-data MIME type:
# Nginx
location ~ \.$ {
add_header Content-Type "multipart/form-data";
}
# Apache
AddType multipart/form-data Use this MIME type in HTML or HTTP:
Content-Type: multipart/form-data <!-- HTML reference --> <link rel="preload" href="file" as="fetch" crossorigin>
Frequently Asked Questions
When should I use multipart/form-data vs application/x-www-form-urlencoded?
Use multipart/form-data when your form includes file uploads or binary data. Use application/x-www-form-urlencoded for simple text-only forms. multipart/form-data is more efficient for binary data because it avoids base64 encoding overhead.
How does the boundary parameter work?
The boundary parameter is a unique string that separates each part of a multipart message. The server uses it to parse the individual form fields and files. Browsers generate a unique boundary automatically.