Content-Disposition Header
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 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.txt’);
Short URL for this post: http://tmblr.co/ZufQ6y1BLPbn