我有一個PHP文件強制下載PDF文件,在一臺服務器(Linux)上它工作正常,但當我將該網站移動到另一臺服務器(Win)時,它開始出現此錯誤:PHP下載PDF拋出錯誤
PHP Warning: readfile(./forms/Form.pdf)
[<a href='function.readfile'>function.readfile</a>]:
failed to open stream: No such file or directory in
D:\CustomerData\webspaces\webspace\wwwroot\Form.php
on line 4
的PHP文件中有這樣的:
<?php
header('Content-disposition: attachment; filename=./forms/Form.pdf');
header('Content-type: application/pdf');
readfile('./forms/Form.pdf');
?>
謝謝!
maybe'filename = ../forms/Form.pdf'? – k102 2012-07-31 09:21:15
它可能只是反斜槓vs(向前)斜線? – Nanne 2012-07-31 09:21:25
也許該文件不存在於froms路徑中,或者您的web服務器標識在路徑上沒有權限?您是否嘗試過使用表單的絕對路徑?錯誤是否持續? – Hinek 2012-07-31 09:22:23