Questions tagged [content-disposition]

The Content-Disposition response header field is used in HTTP web responses to convey additional information about how to process a response payload. It can also be used to attach additional metadata such as a filename to the response.

The Content-Disposition response header field is used in HTTP web responses to convey additional information about how to process a response payload. It can also be used to attach additional metadata such as a filename to the response. The full definition of the content-disposition header is outlined in RFC 6266.

The content-disposition header is added to a HTTP response when further descriptive information is desired to aid the receiver in interpreting the payload. Usage follows the following grammar:

content-disposition = "Content-Disposition" ":" disposition-type *( ";" disposition-parm )

disposition-type = "inline" | "attachment" | disp-ext-type ; case-insensitive disp-ext-type = token

disposition-parm = filename-parm | disp-ext-parm

filename-parm = "filename" "=" value | "filename*" "=" ext-value

disp-ext-parm = token "=" value | ext-token "=" ext-value ext-token =

Questions related to this tag should be concerned with describing the payload of a HTTP Response. An example question may be - "Save a PDF that's been streamed to the browser"

448 questions
6
votes
4 answers

How to change filename prompt text browser Save As dialog?

In my web page (rendered by Rails), I'd like to let the user right-click on a photo to bring up the browser's Save As dialog, to let the user save the photo to their hard drive. However, the photos on my server have unusual filenames (long hex…
lagouyn
  • 376
  • 2
  • 12
6
votes
3 answers

C# ASP.NET 3.5 content-disposition file download problems

I have a sql database that stores some documents. A user can sign into the application, and view a list of their documents. When clicking a linkbutton download in a gridview of their docs, I get the file from the database, write it to the file…
John Batdorf
  • 2,502
  • 8
  • 35
  • 43
6
votes
4 answers

Having issue while downloading a file using content-disposition

I want my program to have a pop-up save as window option before file start downloading, however when I run my servlet it automatically starts downloading the file. What am I missing here ? protected void doGet(HttpServletRequest request,…
Hello World
  • 944
  • 2
  • 15
  • 39
6
votes
2 answers

Python Flask downloading a file returns 0 bytes

Here is the code my flask server is running: from flask import Flask, make_response import os app = Flask(__name__) @app.route("/") def index(): return str(os.listdir(".")) @app.route("/") def getFile(file_name): …
Steven K
  • 441
  • 6
  • 14
6
votes
1 answer

Content-Disposition Filename not working on IE

I am working on an asp.net/c# web application that allows users to view and download PDF files. When I am clicking on a file, I get to view that in the PDF reader available in the browser, and when I save it, the file should be saved with the name…
macha
  • 7,337
  • 19
  • 62
  • 84
6
votes
4 answers

PHP - How to set full directory path in Content-Disposition?

I am passing a filename to a download page. ie somefile.xls The download page adds back in the full directory path onto the filename. ie c:\temp\somefile.xls The problem is that now setting the 'Content-Disposition' of the header doesn't work. The…
John M
  • 14,338
  • 29
  • 91
  • 143
6
votes
2 answers

How can I force a browser to NOT download a file with content-disposition:attachment header

For example: And blah.csv has this header: Content-Disposition: attachment; filename=blah.csv; Is it possible to force blah.csv to render in the iframe instead of downloading?
Matt York
  • 15,981
  • 7
  • 47
  • 51
6
votes
3 answers

handling filename* parameters with spaces via RFC 5987 results in '+' in filenames

I have some legacy code I am dealing with (so no I can't just use a URL with an encoded filename component) that allows a user to download a file from our website. Since our filenames are often in many different languages they are all stored as…
Peter Friend
  • 750
  • 1
  • 7
  • 17
5
votes
1 answer

Header Location + Content Disposition

So I have a downloads page where you click a link, it opens /downloads/download/randomhash randomhash is found in the db, i increment a download counter, and then redirect to the actual file e.g. /uploads/2012/file.png. Everything works except for…
Benno
  • 3,008
  • 3
  • 26
  • 41
5
votes
2 answers

files served with content-disposition: inline still sometimes prompt for download

My subject line says most of what I'm asking. I've got a web site that outputs reports in various formats (HTML, CSV, TSV, Excel, etc). Whenever possible, I'd like these files to be shown in the browser. To that end, I've set up my headers so…
rmeador
  • 25,504
  • 18
  • 62
  • 103
5
votes
2 answers

how to set Content-disposition header as attachment for file part?

I am using the Python requests module to send a multi-part HTTP POST request that contains both form-data and a file attachment. The "Content-disposition" header for each multi-part object is set to "form-data", including the file part. I need the…
user3256235
  • 63
  • 1
  • 2
  • 8
5
votes
2 answers

How to send POST request and get file response?

I want to send POST request (like html form) and get file (HTTP header: "Content-Disposition: attachment; filename="myfile.pdf"). Can you help me?
latata
  • 1,703
  • 5
  • 27
  • 57
5
votes
4 answers

HttpClient wrong encoding in Content-Disposition

I am POST-ing an image with HttpClient and it works well for files with Latin names, but as soon as a name contains any non-ASCII characters it gets transformed to a sequence of question marks. If I create an html form and use a browser to post the…
Monsignor
  • 2,671
  • 1
  • 36
  • 34
5
votes
2 answers

Send file through POST without Content-Disposition in Python

I am using requests in Python to send file over POST. My code looks like this: headers = {'Content-Type': 'application/x-tar', 'Content-Length': tar_size} r = requests.post(server, …
Aerov
  • 205
  • 2
  • 6
5
votes
1 answer

wget breaking with content-disposition

I am trying to download the kml file that is sent via Content-Disposition:attachment from the following website: http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia Using wget and curl with the command: wget --content-disposition…
adlzanchetta
  • 151
  • 1
  • 14