2011-12-20 69 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 2011-12-20 22:06:04

+0

application/pdf。我用網板上的螢火蟲進行了檢查。 – Catfish 2011-12-20 22:08:24

+0

當你問他時,服務器人員說了些什麼? – tadmc 2011-12-20 22:26:51

回答

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 

要生成一個無效的報頭。使用'application/pdf'-type => 'application/pdf''Content-Type' => 'application/pdf'作爲參數header method

相關問題