1
print $page->p("Hello All, Downloading file");
my @contents= $ssh->file_content("$dir/$file", 1);
download(@contents, $file);
...
...
...
sub download {
    use strict;
    my @content = shift;
    my $filename = shift;
    print "Content-Type:application/x-download\n";
    print "Content-Disposition: attachment;filename=$file\n\n";
    print @content;
    return 1;
}

但它不是下载它,而是在屏幕上打印文件的内容。请告诉我我哪里错了?

4

1 回答 1

0

尝试保持您的标头 HTTP 兼容:

print "Content-Type: application/x-download\r\n";
print "Content-Disposition: attachment;filename=$file\r\n\r\n";
print @content;
于 2013-01-14T21:21:51.663 回答