Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Creating dynamically named CGIs

by theguvnor (Chaplain)
on Feb 13, 2002 at 11:46 UTC ( [id://145137]=note: print w/replies, xml ) Need Help??


in reply to Creating dynamically named CGIs

Full marks to the other posts, but the advice about using "Content-Disposition" headers neglects Netscape 4.x browsers (at least in my experience). To get around this difference in browsers, I have used the following snippet of code, with credit going to Merlyn's web techniques column for the path-info-in-query-string trick:

# 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 wo +rks: 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; } }

Hope this helps

..Guv

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://145137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 05:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found