2 my ($query) = $cgi->keywords;
4 my $attachnum = $1 or die 'Invalid attachment number';
5 $FS::CurrentUser::CurrentUser->access_right('Download attachment') or die 'access denied';
7 my $attach = qsearchs('cust_attachment', { attachnum => $attachnum }) or die "Attachment not found: $attachnum";
8 die 'access denied' if $attach->disabled;
10 $r->subprocess_env('no-gzip' => 1); # disable mod_deflate
12 $r->content_type($attach->mime_type || 'text/plain');
13 $r->headers_out->add('Content-Disposition' => 'attachment;filename=' . $attach->filename);
14 $m->print($attach->body);