Tuesday, October 6, 2009

How to make a browser open a pdf as an attachment

You need to set the header 'content-disposition' to attachment, e.g.

content-disposition: attachment;filename=detailedstatement_167.pdf;, inline

Otherwise content-disposition is set to inline which means the browser will open it in the browser window, as if you'd clicked on a link and gone to another page.