blob: c85b1375f9fe5e24d3fe48aa4015483fa3621709 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<%init>
my ($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
my $attachnum = $1 or die 'Invalid attachment number';
$FS::CurrentUser::CurrentUser->access_right('Download attachment') or die 'access denied';
my $attach = qsearchs('cust_attachment', { attachnum => $attachnum }) or die 'Attachment not found: $attachnum';
$m->clear_buffer;
$r->content_type($attach->mime_type || 'text/plain');
$r->headers_out->add('Content-Disposition' => 'attachment;filename=' . $attach->filename);
binmode STDOUT;
print STDOUT $attach->body;
</%init>
|