<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<INPUT TYPE="hidden" NAME="attachnum" VALUE="<% $attachnum %>">
-<BR><BR>
-
-<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
% if(defined $attach) {
% if($curuser->access_right("Download attachment")) {
<A HREF="<% $p.'view/attachment.html?'.$attachnum %>">Download this file</A><BR>
% }
+% }
+
+<BR>
+<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
+% if ( defined $attach ) {
<TR><TD> Filename </TD>
-<TD><INPUT TYPE="text" NAME="filename" SIZE=40 MAXLENGTH=255 VALUE="<% $attach->filename %>"<% $disabled %>></TD></TR>
+<TD><INPUT TYPE="text" NAME="file" SIZE=40 MAXLENGTH=255 VALUE="<% $cgi->param('file') || $attach->filename |h %>"<% $disabled %>></TD></TR>
<TR><TD> Description </TD>
-<TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80 VALUE="<% $attach->title %>"<% $disabled %></TD></TR>
+<TD><INPUT TYPE="text" NAME="title" SIZE=40 MAXLENGTH=80 VALUE="<% $cgi->param('title') || $attach->title |h %>"<% $disabled %></TD></TR>
<TR><TD> MIME type </TD>
-<TD><INPUT TYPE="text" NAME="mime_type" VALUE="<% $attach->mime_type %>"<% $disabled %></TD></TR>
+<TD><INPUT TYPE="text" NAME="mime_type" SIZE=40 VALUE="<% $cgi->param('mime_type') || $attach->mime_type |h %>"<% $disabled %></TD></TR>
<TR><TD> Size </TD><TD><% $attach->size %></TD></TR>
% }
% else { # !defined $attach
my $attachnum = '';
my $attach;
-if ( $cgi->param('error') ) {
- #$comment = $cgi->param('comment');
-} elsif ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
+
+if ( $cgi->param('attachnum') =~ /^(\d+)$/ ) {
$attachnum = $1;
die "illegal query ". $cgi->keywords unless $attachnum;
$attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
or die "Illegal attachnum: ". $cgi->param('attachnum');
my $attachnum = $1;
+my $filename = $cgi->param('file');
+# strip directory names; thanks, IE7
+$filename =~ s!.*[\/\\]!!;
+
my $curuser = $FS::CurrentUser::CurrentUser;
my $delete = $cgi->param('delete');
else {
map { $new->$_($old->$_) }
('_date', 'otaker', 'body', 'disabled');
- $new->filename($cgi->param('filename') || $old->filename);
+ $new->filename($filename || $old->filename);
$new->mime_type($cgi->param('mime_type') || $old->mime_type);
$new->title($cgi->param('title'));
if($delete and not $old->disabled) {
}
else { # This is a new attachment, so require a file.
- my $filename = $cgi->param('file');
if($filename) {
$new->filename($filename);
- $new->mime_type($cgi->uploadInfo($filename)->{'Content-Type'});
+ # use the original filename here, not the stripped form
+ $new->mime_type($cgi->uploadInfo($cgi->param('file'))->{'Content-Type'});
$new->title($cgi->param('title'));
local $/;
<% $attach->usernum ? $attach->access_user->name : $attach->otaker %>
</TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <% $attach->filename %>
+ <% $attach->filename |h %>
</TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <% $attach->title %>
+ <% $attach->title |h %>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <% $attach->mime_type %>
+ <% $attach->mime_type |h %>
</TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
<% size_units( $attach->size ) %>