Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Content-Disposition does not work

Status
Not open for further replies.

kelele

Programmer
May 22, 2001
12
US
I have a link to a word document that opens up the document when you click on it. However, I would like the user to be prompted to download with the usual download dialog box rather than have the document automatically open. I have done some research on using the "Content-disposition" key word, but it does not work for me. Please let me know if there is a problem with my code below or if there is a better way to do this.


#!/usr/local/bin/perl
print("Content-Type = application/ms-word\n\n");
print("Content-disposition: attachment; filename=Test_Doc.doc\n\n");

print &quot;<html>&quot;;
print &quot;<body> &quot;;
print &quot; Download word doc <a href='Test_Doc.doc'>here</a>&quot;;
print &quot;</body>&quot;;
print &quot;</html>&quot;;
 
I think two newline denote the end of the http header, so you can't have two newlines after the Content-type. That's amongst the many reasons I suggest using CGI.pm to generate your headers. It know what they're supposed to look like. Check the docs for the different parameters you can pass to the header() method (like type and attachment). That should generate a proper header, but whether or not that works, I don't know. I think the user's browser settings have to be compatible, too.

Best of luck.

________________________________________
Andrew - Perl Monkey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top