blob: 4c4ca56388728541e80a91b62aff56086a0e6819 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<%init>
$FS::CurrentUser::CurrentUser->access_right('Download attachment')
or die 'access denied';
my ($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
my $attachnum = $1 or die 'Invalid attachment number';
my $attach = qsearchs('cust_attachment', { attachnum => $attachnum })
or die "Attachment not found: $attachnum";
die 'access denied' if $attach->disabled;
$r->subprocess_env('no-gzip' => 1); # disable mod_deflate
$m->clear_buffer;
$r->content_type($attach->mime_type || 'text/plain');
my $filename = $attach->filename;
$filename =~ s/"/'/g; #no idea how to encode " ... \" ? "" ? can't?
$r->headers_out->add(
'Content-Disposition' => qq(attachment;filename="$filename")
);
$m->print($attach->body);
</%init>
|