Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Answer: How do i force the user to download my content?

( #161040=categorized answer: print w/ replies, xml ) Need Help??

Q&A > CGI programming > How do i force the user to download my content? contributed by Joost

As per RFC 2616 (HTTP/1.1), you might try setting the following headers:

Content-Disposition: attachment; filename="fname.ext" Content-Type: application/octet-stream

Note:
In practice the content-disposition only specifies a preferred filename for when you choose "Save as" from your browser-menu.

You also need to set content-type to application/octet-stream if you want the browser to "force" a "Save file as..." popup instead of it trying to display the data first.

Joost.

Comment on Answer: How do i force the user to download my content?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2015-07-02 18:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls