Thread Datei-Download: Kleines Problem (13 answers)
Opened by Gast at 2004-05-02 19:48

esskar
 2004-05-02 20:07
#2300 #2300
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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
sub get_filename
{
my ($file) = @_;
$file =~ s!\\!/!g; # chnage windows path as needed
my @parts = split /\//, $file;
return pop @parts;
}
sub send_file_to_browser
{
my ($file) = @_;
my $name = get_filename($file);
$name =~ s! !%20!g;
$name ||= "[N/A]";

print "Content-Disposition: inline; filename=\"$name\"\n";
print "Content-Type: application/octet-stream\n\n";

send_binaryfile_to_browser($file);

1;
}

sub send_binaryfile_to_browser
{
my ($file) = @_;

binmode STDOUT;
if(open(FILE, "< $file"))
{
binmode FILE;

while(<FILE>) { print $_; }

close FILE;
}
}

View full thread Datei-Download: Kleines Problem