Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

(Guildenstern) Re: Getting CGI to name a file it returns

by Guildenstern (Deacon)
on Jul 16, 2001 at 20:58 UTC ( [id://97087]=note: print w/replies, xml ) Need Help??


in reply to Getting CGI to name a file it returns

Another way to do it is to use the Content-Disposition header.
Set the mimetype to "application/octet-stream", then add a header like this: "Content-Disposition: inline;filename=$filename\n".
Be sure to set the "Content-Length" header as well.

Guildenstern
Negaterd character class uber alles!

Replies are listed 'Best First'.
Re: (Guildenstern) Re: Getting CGI to name a file it returns
by Torgo (Beadle) on Jul 16, 2001 at 22:12 UTC
    Aha. I was sure there was a way to do it without faking out stupid browsers... there'd be hell to pay if ever anyone actually made a good, smart browser!

    Now that I know what to look for, I was searching through cgi.pm, I found some code dealing with Content-Disposition, and looks like they've got it covered through the Attachment parameter:
    print $query->header(-type=>'application/octet-stream', -attachment=>'foo.doc');
    Thanks!

    --
    I write the code while the master is away!
Re: (Guildenstern) Re: Getting CGI to name a file it returns
by one4k4 (Hermit) on Jul 17, 2001 at 16:31 UTC
    inline;filename=$filename is exactly how I did things in this thread. It works great. When the user is first prompted to save the file, it says whatever.cgi, but when they click save (insted of "open from..") it has the correct file name ($filename).

    Just my $0.02

    _14k4 - perlmonks@poorheart.com (www.poorheart.com)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found