Leser: 1
![]() |
|< 1 2 >| | ![]() |
19 Einträge, 2 Seiten |
QuoteDen Namen habe ich ja schon. Und ob die Datei wirklich existiert kann ich ja auch noch anderweitig prüfen (-f -e, etc...)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
opendir DIR, "$TEMP_DIR/" or &file_error("Unable to open directory. $!"); readdir DIR for 0 .. 1; @files = grep -f "$TEMP_DIR/$_", readdir DIR; closedir DIR; my %hash; foreach my $filename (@files) { my($base) = $filename =~ /(.+?)\..+?$/; $hash{$base} = $filename; } my $AttachentFile = $hash{$SessionID}; my $ext = (split /\./, $AttachentFile)[1]; my $MailAttachment = "$TEMP_DIR/$SessionID$ext"; if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");} print "Content-type: text/html\n\n"; print "AttachentFile: $AttachentFile<br>\n"; print "MailAttachment: $MailAttachment<br>\n"; print "ext: $ext<br>\n"; exit;
1
2
3
4
foreach my $filename (@files) { # $filename = '45646.txt';
my($base) = $filename =~ /(.+?)\..+?$/; # $base = 45646;
$hash{$base} = $filename; # $hash{'45646'} = '45646.txt';
}
1
2
3
4
5
6
7
8
9
10
11
my %hash;
foreach my $filename (@files)
{
my($base) = $filename =~ /(.+?)\..+?$/;
$hash{$base} = $filename;
}
my $MailAttachment = "$TEMP_DIR/" . $hash{$SessionID};
if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");}
QuoteIch habe mal versucht deinen Vorschlag einzubauen und die Eegbnisse testweise auszugeben. Bei mir gibt das jedenfalls einen Error 500.
1
2
3
4
5
6
7
8
9
10
11
my %hash;
foreach my $filename (@files)
{
my($base) = $filename =~ /(.+?)\..+?$/;
$hash{$base} = $filename;
}
my $MailAttachment = "$TEMP_DIR/" . $hash{$SessionID};
if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
opendir DIR, "$TEMP_DIR/" or &file_error("Unable to open directory. $!"); readdir DIR for 0 .. 1; @files = grep -f "$TEMP_DIR/$_", readdir DIR; closedir DIR; my %hash; foreach my $filename (@files) { my($base) = $filename =~ /(.+?)\..+?$/; $hash{$base} = $filename; } my $MailAttachment = "$TEMP_DIR/" . $hash{$SessionID}; my $ext = (split /\./, $MailAttachment)[-1]; my $picturename = "bild"; if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");} use MIME::Lite; # Create a new multipart message: $msg = MIME::Lite->new( From =>"$CompanyName <$CompanyEmail>", To =>"$CompanyName <$CompanyEmail>", Cc =>'', Subject =>"Nachricht von $company", Type =>'multipart/mixed' ); # Add parts (each "attach" has same arguments as "new"): $msg->attach(Type => 'text/html', Data => qq { bla, bla } ); # Add the attachment and automaticly determine the content type: $MIME::Lite::AUTO_CONTENT_TYPE = 1; $msg->attach( Type =>'auto', Path =>"$MailAttachment", Filename =>"$picturename.$ext", Disposition =>'attachment' ); $msg->send;
my $filename = glob ("$TEMP_DIR/$SessionID.*");
if ($FunktionertAllesSoWieEsSoll eq 'ja') {print "Laß es so!";}
![]() |
|< 1 2 >| | ![]() |
19 Einträge, 2 Seiten |