my $csv_path = "/home/temp/domain.csv";
my $ID = "domain.csv";
my $encode_ID = uri_escape($ID);
if ((defined $ID) && ($ID ne ''))
{
print "Content-Type:application/x-download\n";
if ($ENV{'HTTP_USER_AGENT'} =~ /MSIE/) {
print "Content-Disposition:attachment;filename=$encode_ID\n\n";
}elsif ($ENV{'HTTP_USER_AGENT'} =~ /Firefox/){
print "Content-Disposition:attachment;filename*=\"utf8''$encode_ID\"\n\n";
}else{
print "Content-Disposition:attachment;filename=$ID\n\n";
}
binmode STDOUT;
open(F, "<$csv_path") or die("No this csv:$!\n");
binmode(F);
my $buf="";
while(read(F,$buf,1024)){
print $buf;
}
close(F);
}
转载自原文链接, 如需删除请联系管理员。
原文链接:使用perl下载文件,转载请注明来源!