- $previous = _store_value($uploads, $name, '') if ($name);
- $target->{FILENAME} = $filename if ($filename);
+ if ($name) {
+ # legacy, some old upload routines expect this to be here
+ $temp_target->{FILENAME} = $filename if defined $filename;
+
+ # name can potentially be both a normal variable or a file upload
+ # a file upload can be identified by its "filename" attribute
+ # the thing is, if a [+] clause vivifies atructur in one of the
+ # branches it must be done in both, or subsequent "[]" will fail
+ my $temp_target_slot = _store_value($temp_target, $name);
+ my $target_slot = _store_value($target, $name);
+
+ # set the reference for appending of multiline data to the correct one
+ $previous = defined $filename ? $target_slot : $temp_target_slot;
+
+ # for multiple uploads: save the attachments in a SL/Mailer like structure
+ if (defined $filename) {
+ my $target_attachment = _store_value($target, "ATTACHMENTS.$name", {});
+ my $temp_target_attachment = _store_value($temp_target, "ATTACHMENTS.$name", {});
+
+ $$target_attachment->{data} = $previous;
+ $$temp_target_attachment->{filename} = $filename;
+
+ $p_attachment = $$temp_target_attachment;
+ }
+ }