How can I control the default filename when downloading a file via CGI?
(from a newsgroup post by Matthew Healy) One option, assuming you aren’t already using the PATH_INFO environment variable, is just to call your CGI script with extra path information. For example, suppose the URL to your script is actually http://example.com/scriptname?name1=value1&name2=value2 Instead, try calling it as http://example.com/scriptname/filename.ext?name1=value1&name2=value2 and note that you need to escape the URL if it’s in an HTML page: http://example.com/scriptname/filename.ext?name1=value1&name2=value2 And probably the browser will assign the name given in the last chunk as the suggested filename for downloading. This works because the http server looks for the program file to run, then passes any extra path to the program as PATH_INFO variable; the browser cannot tell where the SCRIPT_NAME part ends and the PATH_INFO part begins.