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

The website I support allows companies and clubs to maintain the mailing lists on line. They can download the list as a CSV list to use in their own label printing software. I create the list normally and send it to them via this routine:
# # GET THE LABEL FILE # $key = 'Labels'; $file = "$path/labels/$key"; # # SEND THE FILE TO THE BROWSER # print "Content-Disposition: attachment; filename=$key.txt\n"; print "Content-Type: application/octet-stream\n\n"; my $buffer; open (FILE, "$file"); print $buffer while read(FILE, $buffer, 4096); close FILE;
Normally the receipient's browser show's the file as 'Label.txt'. However I have a customer that is using XP Home and they keep getting a notice that says the file is a '.cgi'. I have them change the file type to '.txt'. I've tested this little code above on XP Professional and I don't have this problem. Any ideas? Thanks, Ron

Replies are listed 'Best First'.
Re: Downloading a file to XP Home changes the extenstion
by amonotod (Acolyte) on Oct 17, 2003 at 19:55 UTC
    Change the link, i.e.: instead of
    /cgi-bin/download.cgi?getlabels
    use
    /cgi-bin/download.cgi/GetLabels.txt

    It won't affect your script drastically, and will help your user. Basically, it just fools the stupid browser...

    HTH,
    amonotod
Re: Downloading a file to XP Home changes the extenstion
by hardburn (Abbot) on Oct 17, 2003 at 19:45 UTC

    This smells like a browser that's not following the standard correctly. All you can do is ask them to use a different browser, or find the bizzare combination of config options that created this behavior.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    :(){ :|:&};:

    Note: All code is untested, unless otherwise stated