# determine the http header to send the browser client: my $user_agent = $q->user_agent; # CGI query object if ($user_agent =~ m/MSIE/i) { # for IE users, the following works: print "Content-Disposition: attachment; filename = $name\n\n"; } else { # for Netscape clients, need to do a 2-pass trick here... if ($q->path_info() ) { # 2nd pass: collect the extra path info which Netscape client # will use to name the downloaded file: print $q->header('application/x-octet-stream'); } else { # 1st pass: add the name info to the http header path info var # and redirect back upon itself for the 2nd pass: $q->path_info("/$name"); print $q->redirect($q->self_url()); exit; } }