Einzelnen Beitrag anzeigen
Alt 06.05.2003, 03:59   #1
werner2k
Newbie
 
Registriert seit: 05.11.2001
Alter: 65
Beiträge: 4


Frage Perl-Downloadscript

Für eine Webanwendung habe ich eine Kette von Perl-Scripts geschrieben, unter anderm den folgenden Code für das Download von Dateien:

use strict;
use common;
use Mail::POP3Client;
use MIME::Parser;
use configwm;
use CGI;
use nswmauth;

#obtain the FORM information that has been passed by using
#the param() method of the cgi object.
my $query=new CGI;
my $nswmc=new common;
my $nswmau = new nswmauth;
my $loginname = $query->param("loginname");
my $pkey = $query->cookie(-name=>'PKEY');
my $password = $query->param("password"); # encrypted password !!!
my $POPserver = $query->param("POPserver");
my $msgid = $query->param("id");
my $cache = $query->param("cache");

my $browser = $ENV{'HTTP_USER_AGENT'};

$|=1;

# authenticate for download
if ($nswmau->isAuthOK($loginname,$nswmc->decryptit($password,$query->cookie("PKEY")),$POPserver)==0) {
print "</HEAD><BODY>";
print "<font size=+1>$POPserver: $loginname, $conf::incorrectlogin";
exit;
}
my $attch = $query->param("file");
my $mimetype=$nswmc->mimetype($attch);

# do the download
print "Content-type: $mimetype\n\n";
print "Content-disposition: attachment; filename=$attch";
print "\r\n" if (!$conf::modperl);
open(ATTCH, "<$conf::temppath/$attch");
binmode ATTCH;
while(<ATTCH>) {
print $_;
}
close(ATTCH);

exit;

Er funktioniert recht gut - nur erscheint im "Save-as"-Fenster des Browsers (egal ob Opera oder IE) als Dateiname immer der Name des aufgerufenen CGI-Files (gespeichert wird allerdings die korrekte Datei).
Weiss jemand Rat??
Danke im Voraus!!
werner2k ist offline   Mit Zitat antworten