theqblas has asked for the wisdom of the Perl Monks concerning the following question:

Uhm, I have a CGI that's generating dynamic web logs, or simply sending a stored copy of the web log. I'm wondering if there's any MIME header I can send to a web browser to have it change the filename of what I'm sending instead of having it use the script name ??? For example:
www.blah.org/cgi-bin/get-weblog?param=foo&param2=foo2
the web browser by default wants to save the file as 'get-weblog', but I want it to save it as a different filename by default..

Any ideas??

Replies are listed 'Best First'.
Re: Sending named files via CGI
by merlyn (Sage) on Apr 17, 2001 at 22:49 UTC
Re: Sending named files via CGI
by Rhandom (Curate) on Apr 18, 2001 at 01:46 UTC
    Even though this is in the places merlyn mentioned above ... if you search for it...

    Most browsers will typically use whatever is after the last / in the url. So, it you go to http://mydomain.com/cgi-bin/mycgi it will try to download and save the file as "mycgi". To take care of this (assuming you are using Apache), just add on another file name. For example http://mydomain.com/cgi-bin/mycgi/myrealfilename.txt . Apache will parse up the directory tree until it finds an executabe, in this case "cgi-bin/mycgi". After that the rest will get stuffed in the variable $ENV{PATH_INFO}. In this case $ENV{PATH_INFO} would contain "/myrealfilename.txt". If you begin the download when the file matches http://mydomain.com/cgi-bin/mycgi/myrealfilename.txt the user will be prompted to save "myrealfilename.txt".