Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How do i return a file with CGI and suggest a file name to 'save as'

by cLive ;-) (Prior)
on Jul 20, 2001 at 22:31 UTC ( [id://98490]=perlquestion: print w/replies, xml ) Need Help??

cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

How do i return a file with CGI and suggest a file name to 'save as'

Originally posted as a Categorized Question.

  • Comment on How do i return a file with CGI and suggest a file name to 'save as'

Replies are listed 'Best First'.
Re: How do i return a file with CGI and suggest a file name to 'save as'
by cLive ;-) (Prior) on Jul 20, 2001 at 22:33 UTC
    use CGI;

    when printing the file to the browser, use the following header:

    print $query->header(-type=>'application/octet-stream', -attachment=>'foo.doc');
      PS - this doesn't work with all browsers. So, if you can, append your script URL as follows when you call it (this seems to sort out most situations):
      http://my.domain/url/of_script.cgi/suggested_filename
      where 'suggested_filename' is the name you want the file saved as.
Re: How do i return a file with CGI and suggest a file name to 'save as'
by Guildenstern (Deacon) on Jul 20, 2001 at 23:00 UTC
    Use the Content-Disposition header and specifiy the filename from within there. See BBQ's take on this here.

Log In?
Username:
Password:

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

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

    No recent polls found