ダウンロードCGIのPerlスクリプト
以下のソースは、ファイルのダウンロードのサンプルスクリプトです。
#!/usr/local/bin/perl use strict; #宣言 my $FilePath = 'C:\Inetpub\wwwroot\bin\files\xxx.csv'; # ダウンロードファイル my @FileName = split(/\\/, $FilePath); #ダウンロードファイルオープン open (DF, $FilePath) or die "cannot open '$!'"; #ヘッダー部ダウンロード print <<"HERE1"; Content-type: application/octet-stream Content-Disposition: attachment; filename=$FileName[$#FileName] HERE1 #本体ダウンロード binmode DF; binmode STDOUT; while (my $DFdata = <DF>) { print STDOUT $DFdata; } #ダウンロードファイルクローズ close DF;
ちなみに、アップロードはCGI.pmモジュールを使うと吉です。