Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Forcing a Word Document to Download

by Mr_Person (Hermit)
on Jul 14, 2003 at 16:03 UTC ( [id://274021]=note: print w/replies, xml ) Need Help??


in reply to Forcing a Word Document to Download

I don't have a machine with Word on it handy to test, but I've had good luck with the following code to have the browser download the output of the CGI instead of just showing it.
#!/usr/bin/perl use strict; use warnings; use CGI; my $cgi = CGI->new; my $dir = '/path/to/file'; my $file = 'file.doc'; open(FILE, "$dir/$file") or die "Error opening file $file: $!"; print $cgi->header( -type => 'application/octet-stream', -attachment => $file, ); while(<FILE>) { print; } close(FILE);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found