Ano-Tech Computers
Enter keyword:

How to write a CGI script that generates a semicolon separated file
Problem:
When generating web content on-the-fly, the standard HTTP header used is "Content-type: text/html". However, this means the user has to actively click "File" and "Save as..." to get a file save dialogue. Furthermore, the default filename is the same as the CGI script filename.
 
Solution:
Use the following HTTP header instead:

Content-type: application/octet-stream
Content-Disposition: attachment; filename="filename.ext"


This will cause most browsers to pop up the file "Save as..." dialogue automatically. Note that you may NOT specify a path.

 
Discuss this solution
Did this article solve your problem? Yes No Did not apply

We welcome anyone who is willing to contribute to this public knowledge base, contact siteadmin@atc.no if you have information you would like to share. The idea is not to replace the commercial support sites, but to publish those hard-to-find solutions you've found yourself looking for over and over again.

Show all articles