Content · Response header
Content-Disposition
Controls whether a resource is displayed inline or triggered as a download.
What is Content-Disposition?
Content-Disposition tells the browser how to present the resource. `inline` (default) tries to render it in the page; `attachment` forces a download prompt with the given filename.
Typical usage
Set on responses that should be downloaded rather than opened in the browser.
Examples
Force download
Content-Disposition: attachment; filename="report.pdf"Multi-byte filename
Content-Disposition: attachment; filename*=UTF-8''%E6%8A%A5%E5%91%8A.pdfCommon gotchas
For non-ASCII filenames, use `filename*` with UTF-8 percent-encoding (RFC 5987). Legacy `filename=` may be mojibake in older browsers.
Also known as
Also commonly written as: content disposition · content-disposition header · content disposition header · content disposition attachment · content disposition filename · content-disposition attachment filename · content disposition inline. These variants — including plural forms, unhyphenated spellings, and Japanese (ヘッダ) — all refer to the same Content-Disposition HTTP header.
Specification
RFC 6266
Frequently asked questions
What is the Content-Disposition HTTP header?
Content-Disposition tells the browser how to present the resource. `inline` (default) tries to render it in the page; `attachment` forces a download prompt with the given filename.
Is Content-Disposition a request or response header?
Content-Disposition is a response header — the server sends it to the client. Set on responses that should be downloaded rather than opened in the browser.
What does a Content-Disposition header look like?
A typical Content-Disposition header looks like: Content-Disposition: attachment; filename="report.pdf" (Force download).
What are common mistakes with Content-Disposition?
For non-ASCII filenames, use `filename*` with UTF-8 percent-encoding (RFC 5987). Legacy `filename=` may be mojibake in older browsers.
Related headers
Content-Type
Declares the media type of the body.
Content-Length
The size of the body in bytes.
Content-Encoding
How the body has been transparently encoded (usually compressed).
Accept
Which media types the client can process.
Last-Modified
When the resource was last modified.
Cache-Control
Directives that control caching behavior.
Vary
Which request headers cause different cached variants of the response.
Location
The redirect target (3xx) or newly created resource URL (201).