2013-05-20 31 views
0

我使用PHP & MySql將報告導出爲ex​​cel。我可以使用我的源代碼從本地主機導出和打開文件,但無法在服務器中執行。當我嘗試導出它時,顯示 「 Warning: tempnam() [function.tempnam]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home:/tmp:/usr) in /home/xx/xx.inc.php on line 205.」 我使用Google搜索,但我無法獲得解決方案。在PHP報告中導出爲ex​​cel錯誤

$ this - > _ tmpfilename = tempnam(「/ tmp」,「excelreport」);

$ fh = fopen($ this - > _ tmpfilename,「w + b」);

這是使用的代碼。怎麼了。

+0

是您使用的庫創建Excel文件檢查您的服務器臨時路徑和必要的文件夾權限 – swapnesh

+0

?如果它使用臨時文件,那麼它應該提供一些方法讓你說這些文件的創建位置 –

+0

我使用php_writeexcel/Johan撰寫 – Raj

回答

0

您的主機在您的主文件夾中限制您的PHP活動。在您的個人文件夾(即/home/xx/tmp/)內創建一個tmp文件夾,chmod it 777來解決此問題。

注意:/tmp文件夾由服務器自身使用。在共享的託管環境中,你往往限制爲不接觸服務器的系統文件夾(比/home其他文件夾)

+0

我試過並且仍然是相同的警告消息 – Raj

+0

文件的完整路徑是什麼? – Raptor

+0

/home/xx/public_html/pms/excelreport – Raj