<?xml version="1.0" encoding="windows-1252"?>
<node id="342223" title="Re: Force download -- Repost" created="2004-04-02 22:27:40" updated="2004-08-22 18:16:14">
<type id="11">
note</type>
<author id="6040">
Kozz</author>
<data>
<field name="doctext">
Your main problem is that you're only outputting the header and not the contents of the file itself.  If you're going to output your own mime-type header like this, you would then need to open the file in question (use binmode()) in chunks, outputting those chunks to the browser as they are read.
&lt;code&gt;
my $buffer;
open(DOWNLOAD, "&lt; /path/requested_file") or die "Could not read file: $!";
binmode(DOWNLOAD);
while( read(DOWNLOAD, $buffer, 4096) ){
   print $buffer;
}
close(DOWNLOAD);
&lt;/code&gt;

"Forcing a download" is really a function of the browser, and results from the browser's decision on how to handle the particuar mime type you send.  You may want to also try "application/binary" in addition to the "application/octet-stream".

In your code, I think that using 'join' is a bit of overkill when you can concatenate the strings as
&lt;code&gt;
my $load_file = $dl_file . $file;
&lt;/code&gt;
Also, I would get rid of the start_html and end_html bit -- unnecessary, and I suppose could mess up your headers, too.
</field>
<field name="root_node">
342219</field>
<field name="parent_node">
342219</field>
</data>
</node>
