
What Is the Content-Disposition Header?
In HTTP, the Content-Disposition response header indicates whether a browser should process a resource normally (such as displaying an image) or treat it as a downloadable attachment. It can also suggest a filename for saving the resource.
For media applications, this helps distinguish between previewing an asset and downloading a copy. The same image or document can support either experience depending on the response headers and browser behavior.
The header also serves a different purpose inside multipart form submissions, where it identifies individual fields and uploaded files.
How Content-Disposition Works
Inline Display and Attachments
The two main disposition types for HTTP responses are inline and attachment.
inlinerequests normal processing according to the resource’s media type. A supported image might appear in the browser, while a PDF might open in a document viewer.attachmentrequests download handling. For example,Content-Disposition: attachment; filename="studio-reference.jpg"suggests saving the response as an attachment with that filename.
Multipart Body Header
A multipart/form-data request uses the Content-Disposition header to describe each part of the form, including individual fields and uploaded files. Each header begins with the form-data directive and must include a name parameter that identifies the associated field.
Additional directives are case-insensitive, and their values can be written as either tokens or quoted strings. Quoted strings are generally recommended because many server implementations require them. Tokens used in MIME headers like Content-Disposition must contain only US-ASCII characters, which limits the values they can represent.
Content-Disposition vs. Content-Type
| Header | Purpose | Example |
|---|---|---|
| Content-Type | Identifies the response’s media type | image/jpeg |
| Content-Disposition | Indicates intended handling and optionally a save name | attachment; filename=”sample.jpg” |
inline doesn’t provide support for an unfamiliar format. Browser capabilities, preferences, and other instructions still influence the result. For example, an honored HTML download attribute can override an inline disposition.
Content-Disposition in Multipart Uploads
In a multipart/form-data request, each body part has its own Content-Disposition header using the form-data disposition.
The required name parameter identifies the corresponding form field. A file part can also include filename, representing the submitted filename. These headers belong inside the multipart body, rather than acting as a download instruction for the entire request.
Multipart upload rules differ from response-header rules. In particular, RFC 7578 does not permit the filename* parameter in multipart/form-data parts.
