2011-12-20 38 views
0

私はperlスクリプトにファイルを読み込み、そのファイルタイプに基づいてヘッダを適切に設定しようとしています。 PDFは表示されず、私のサーバーの人はこのことがロックされていると思っています。このスクリプトで間違っていることはありますか?perlスクリプトで読むとブラウザにPDFが表示されない

my $q = CGI->new; #instantiate the CGI object 
my $filename = $q->param('file'); # get the file param from the query string 
my $text = read_file($filename); # read in the file 

my($name, $path, $suffix) = fileparse($filename, qr/\..*/); 

if($suffix eq ".pdf") { 
    print $q->header('Content-type: application/pdf'); 
} else { 
    print $q->header('text/html'); 
} 
+0

クライアント側で実際に見ているヘッダは何ですか? – friedo

+0

アプリケーション/ pdf私はネットパネルで火かき棒でチェックした。 – Catfish

+0

あなたが彼に尋ねたとき、サーバーの人は何を言ったのですか? – tadmc

答えて

4
$ perl -MCGI -E'my $q = CGI->new; print $q->header("Content-type: application/pdf");' 
Content-Type: Content-type: application/pdf; charset=ISO-8859-1 

無効なヘッダを生成しています。 header methodの引数として'application/pdf'または-type => 'application/pdf'または'Content-Type' => 'application/pdf'のいずれかを使用してください。

関連する問題