X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main_attach.cgi;h=cdf93ceabb3b6f4f07707196de0baa7c3f5446c8;hp=09271412202b7ec1ffa8d7312c14048c236af547;hb=25efd7207d9ea9be4bea1093917c0d8dc4b1e87a;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/httemplate/edit/process/cust_main_attach.cgi b/httemplate/edit/process/cust_main_attach.cgi index 092714122..cdf93ceab 100644 --- a/httemplate/edit/process/cust_main_attach.cgi +++ b/httemplate/edit/process/cust_main_attach.cgi @@ -7,11 +7,7 @@ % $act = 'purged' if($attachnum and $purge); % $act = 'undeleted' if($attachnum and $undelete); % $act = 'deleted' if($attachnum and $delete); -<% header('Attachment ' . $act ) %> - - +<& /elements/popup-topreload.html, mt("Attachment $act") &> % } <%init> @@ -24,9 +20,11 @@ $cgi->param('attachnum') =~ /^(\d*)$/ 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 $otaker = $curuser->name; -$otaker = $curuser->username if ($otaker eq "User, Legacy"); my $delete = $cgi->param('delete'); my $undelete = $cgi->param('undelete'); @@ -36,7 +34,7 @@ my $new = new FS::cust_attachment ( { attachnum => $attachnum, custnum => $custnum, _date => time, - otaker => $otaker, + usernum => $curuser->usernum, disabled => '', }); my $old; @@ -51,9 +49,9 @@ if($attachnum) { 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')); + $new->title( scalar($cgi->param('title')) ); if($delete and not $old->disabled) { $new->disabled(time); } @@ -64,11 +62,13 @@ if($attachnum) { } 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'}); - $new->title($cgi->param('title')); + # use the original filename here, not the stripped form + $new->mime_type( + $cgi->uploadInfo( scalar($cgi->param('file')) )->{'Content-Type'} + ); + $new->title( scalar($cgi->param('title')) ); local $/; my $fh = $cgi->upload('file');