rfc-2388

Returning Values from Forms: multipart/form-data

L. Masinter
date1998-08 streamLegacy statusPROPOSED STANDARD pages9 canonicalhttps://www.rfc-editor.org/rfc/rfc2388 doi10.17487/RFC2388 errataview
This specification defines an Internet Media Type, multipart/form-data, which can be used by a wide variety of applications and transported by a wide variety of protocols as a way of returning a set of values as the result of a user filling out a form. [STANDARDS-TRACK]

obsoleted by

Extracted elements (21)

design-rationale §5.2

Despite high overhead for forms with many short-value fields, multipart/form-data is justified because in practice (e.g., HTML forms) the average overhead is not significant, and the format supports content-type labeling and charset encoding that application/x-www-form-urlencoded cannot.

http

design-rationale §5.2

The multipart/form-data encoding was chosen over proposed alternatives such as a new 'aggregate' MIME top-level type or a 'packet' content-transfer-encoding because multipart mechanisms are well established, simple to implement on both client and server, and as efficient as other methods.

http

design-rationale §5.7

The specification intentionally provides no mechanism to correlate multipart/form-data with the originating form, because many different forms might transmit the same data. Applications may use a specific ACTION URL or hidden fields for this purpose.

http

interoperability-note §5.6

Many web applications use 'application/x-www-form-urlencoded' for form data, which is more compact but provides no opportunity to label data with content type, apply a charset, or use other encoding mechanisms. Applications may need to support both formats.

http

interoperability-note §5.5

The ordering of fields within a form and the ordering of returned values in multipart/form-data is not defined by this specification; nor is handling of multiple fields with the same name. Intermediaries SHOULD NOT reorder results.

http

normative-requirement §4.1 MUST

A boundary MUST be selected that does not occur in any of the data. Each field is sent as a part in the order defined by the sending application and form.

http

normative-requirement §3 SHOULD

Each part has an optional Content-Type, which defaults to text/plain. File inputs should use the appropriate media type if known, or 'application/octet-stream' if unknown.

http

normative-requirement §3 MUST

Each part of a multipart/form-data message MUST contain a Content-Disposition header with disposition type 'form-data' and a 'name' parameter whose value is the original field name in the form.

http

normative-requirement §4.1 SHOULD

Each part SHOULD be labelled with an appropriate Content-Type if the media type is known (e.g., inferred from file extension or OS type information) or as 'application/octet-stream'.

http

normative-requirement §5.4 SHOULD

Field names containing characters outside US-ASCII SHOULD be encoded using the method in RFC 2047, because MIME headers are generally required to consist only of 7-bit US-ASCII data.

http, email

normative-requirement §3 SHOULD

If multiple files are returned as the result of a single form entry, they SHOULD be represented as a 'multipart/mixed' part embedded within the multipart/form-data.

http

normative-requirement §4.3 MAY

If the value of a part does not conform to the default encoding, the part may need to be encoded and a 'content-transfer-encoding' header supplied. For mail transport, the default is 7BIT encoding.

http, email

normative-requirement §4.4 MAY

The sending application MAY supply a file name via the 'filename' parameter in the Content-Disposition header. If the sender's OS filename is not in US-ASCII, it might be approximated or encoded using RFC 2231.

http

protocol-element §4.4

For file inputs, the original local file name may be supplied as a 'filename' parameter in 'content-disposition: form-data', or in a 'content-disposition: file' header of the subpart when multiple files are submitted.

http

protocol-element §4.5

For text fields, the charset parameter of Content-Type indicates the character encoding used. For example, 'content-type: text/plain;charset=windows-1250' with quoted-printable encoding for non-ASCII text.

http

protocol-element §3

multipart/form-data is a MIME media type for returning a set of form field values. It follows all multipart MIME rules from RFC 2046 and contains a series of parts, each corresponding to a named form field.

http, email

registry §Appendix A

This document registers the media type 'multipart/form-data' with required parameters: none; optional parameters: none. Encoding considerations follow those for other multipart MIME types.

registry, http

security-consideration §6

The introduction of form-data that can send back file contents from a user's file system creates risk from automated scripts that fill out forms and transmit local files to a remote address. Additional caution is required when executing automated scripting involving multipart/form-data.

security, http

security-consideration §6

User applications requesting form information must ensure users do not send information unwillingly or unwittingly to the requestor or a third party. A form could be crafted to send spam or private information to unintended parties.

security, privacy, http

security-consideration §6

When interpreting Content-Disposition, implementations must not inadvertently overwrite files in the recipient's address space. The 'filename' parameter in particular must be treated carefully to prevent path traversal attacks.

security, http

wire-format §3

The Content-Disposition header for each part takes the form: 'Content-Disposition: form-data; name="fieldname"'. The 'name' parameter carries the original HTML/form field name and is required for each part.

http