filmo has asked for the wisdom of the Perl Monks concerning the following question:

Okay, so I've got a link in the page like this:
<a href="perl.cgi?random_id=23ljasdf09">
Which of course links to the correct file and pulls up the correct directory information from the database. perl.cgi then creates a URL string like this
$URL = "/base_directory/client/job/final.doc";
Where the 'final.doc' is the document refreneced by the 'random_id' in the original HREF link. (There are other checks in place, not shown here.)

Next, I want to 'push' that document to the user and have tried variations of:

print "Location: www.mysite.com/$URL";
And I end up with various results depending on the browsers. (some, on Windoz either open the file in Word or save it to disk; on Mac, it saves the file under the name "perl.cgi" instead of "final.doc" ??) What I'd really like is for the client to be able to click on the link and have the finished MS Word document saved to their disk (assuming they consent.) What's the best approach to this. I'm sure I must be doing something rather simple wrong. Thanks.

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: pushing requested file
by gav^ (Curate) on Feb 08, 2002 at 14:48 UTC
    or:
    use CGI; my $cgi = CGI->new; print $cgi->header(-location => "http://www.mysite.com/$URL");
    I tested this on IE and it opens the word document straight into the browser window.

    Hope this helps...

    gav^

Re: pushing requested file
by abaxaba (Hermit) on Feb 16, 2002 at 20:45 UTC
    Another approach might be this:
    open (FILE, "/path/to/$URL"); binmode (FILE); print "Content-type:application-vnd.ms-word\n\n"; while (<FILE>) { print; }
    hth...
Re: pushing requested file
by silent11 (Vicar) on Feb 08, 2002 at 14:01 UTC
    try
    print "Location: www.mysite.com/$URL\n\n";
Re: pushing requested file
by Anonymous Monk on Aug 28, 2002 at 18:02 UTC
    ddddddd

    Originally posted as a Categorized Answer.