Content-Disposition Header
Friday, April 10, 2009
In situations where you want a file linked to from within a website to present a 'Save As' dialog rather than simply displaying the content ... you can inject a Content-Disposition header into the HTTP connection to prompt the browser to do so. I recently had a situation where I was linking to an uncommon file extension through a reverse-proxy and Internet Explorer 6 wanted to include extra URI information in the 'Save As' file name. You can force the saved file name with this header as well.
In PHP, the header is introduced as follows...
header('Content-type: text/plain');header('Content-Disposition: attachment; filename=myfile.ext');
Additional information, and my source for this information, can be found here.
posted by Don @ 3:18 PM,
0 Comments:
Links to this post:
About This Blog
This blog is a place where I hope to put the snippets and trimmings of my geek'dom ... code samples that have served me well, tech links and other such things that'll I find useful. In short, any time I have to Google something, I tend to post it here for others to find as well.
Also, having owned 'digital-penguin.com' for many years and having worked with many a fellow geek, this site also serves as a place where I can always be found.

Post a Comment