Sorry about not including the code. I'm new here. It's below. The error message I received was a vague MS message as I noted in my first request: 'The document or path is invalid. Try using the Word open dialog.' No clue what that means.

Anyway, your suggestion to compare the files led to a clue. It turns out that my read buffer size was too small.

Thanks for your help. Please give me any other helpful hints if you see something I could improve.

#!/usr/bin/perl -wT

use strict;
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
use Archive::Zip;
use Archive::Zip::MemberRead;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

my $files_location;
my $ID;
my $FN;
my $buffer;
my @filespec;

$files_location = "/home/public_html/test";

$ID = param('ID');
$FN = param('FN');

if ($ID eq '' || $FN eq '') {
print "Content-type: text/html\n\n";
print "Invalid Request";
} else {
local($/) = undef;
my $zipName = "$files_location/$ID";
my $zip = new Archive::Zip($zipName);
my $fh = new Archive::Zip::MemberRead($zip, $FN);
my $read = $fh->read($buffer, 1024*1024);
die "FATAL ERROR reading my secrets !\n" if (!defined($read));
$fh->close();
binmode STDOUT;
@filespec = split("/", $FN);
#print "Content-Type:application/x-download\n";
print "Content-Type:application/msword\n";
print "Content-Disposition:attachment;filename=$filespec1\n\n";
print $buffer;
}

sub Error {
print "Content-type: text/html\n\n";
print "The server can't use $_[0] and $_1: $! \n";
exit;
}


In reply to Re: Re: Download Word Docs by Tk
in thread Download Word Docs by Tk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.