Content-Disposition Header

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.

  • inline requests 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.
  • attachment requests 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.

QUICK TIPS
Jen Looper
Cloudinary Logo

Here are some tips to better understand content disposition:

  1. Choose handling per endpoint.
    Configure preview and download routes according to their intended experience.
  2. Keep the media type accurate
    Set the appropriate Content-Type even when delivering an attachment.
  3. Use compatible filename encoding
    For international response filenames, provide filename* with an ASCII filename fallback.
  4. Treat uploaded names as input
    Validate them and choose storage paths independently of client-provided directory information.
  5. Inspect the final delivered response
    Test redirects, cached responses, and representative browsers when troubleshooting behavior.
Last updated: Nov 26, 2026
★★★★★
4.7 (30 reviews)
Talk to Sales Talk to Sales