scoobyrico has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl ########################################################## use CGI qw(cookie header param); # parse form inputs my $file=param('file'); my $format=param('format'); if ($format eq 'Excel') { $type='binary'; $format='application/vnd.ms-excel'; } elsif ($format eq 'Comma') { $type='text'; $format='text/csv'; } else { $type='text'; $format='text/tsv'; } my $file = "/download/".$file; my $file2=$file; $file2=~s#download/##; print header( -type => qq($format; name="$file2"), -Content_disposition => qq(inline; filename="$file2") ); my $members=readfile($file,$type); print $members; exit; #======================================================== sub readfile { local($filename,$type)=@_; open(FILE,"<$filename"); if ($type eq 'binary') { binmode FILE; } local $/; $text=<FILE>; close(FILE); return $text; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Safari downloading files
by Joost (Canon) on Aug 16, 2007 at 16:03 UTC | |
by scoobyrico (Beadle) on Aug 16, 2007 at 16:16 UTC |