It looks like you are trying to build a multipart MIME entity containing the document (because of your use of boundaries) but you haven't got the right type on it. But:
- It's not done correctly (the Content-Type: for a multipart would be multipart/mixed, not text, which is not a valid MIME type.
- You do not need a multipart because it looks like you are trying to send only one thing (the document).
- Browsers won't support receiving a multipart MIME message anyway over HTTP (this facet of MIME is reserved for email, not HTTP, especially Content-Transfer-Encoding: base64.
Also, you get $bufsize to 60*57 (any special reason to pick this number 3420?) and you loop as long as it is still equal to 3420, which it always is since you never change it. It will loop forever.
What you need to do is far simpler:
if (open (INHOUD, "$regel")) {
binmode INHOUD;
print << "EOT1";
Content-Type: application/msword; filename="bw051122.doc"
EOT1
while (read(INHOUD, $buffer, 4096) {
print $buffer;
};
close (INHOUD);
As a bonus, if you always send the same document, you could add Last-Modified and Expires headers to enable the client to cache the result just like if you have been able to do if the web server had served the file directly.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.