0
我試圖通過PHP文本添加到新的生產服務器不插入,如果同樣我嘗試在我的本地機器上發生,我已經給予所有權限在服務器,雖然該文件夾中不保存這個聲音逗我想,谷歌表示,仍然是所有可能的方式不是在目錄中工作PHP不寫文本到txt文件的Windows服務器2012 R2
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file! " . var_export(error_get_last(), true));
$txt = "Mickey Mouse\n";
fwrite($myfile, $txt);
$txt = "Minnie Mouse\n";
fwrite($myfile, $txt);
fclose($myfile);
?>
輸出誤差與
PHP Warning: fopen(newfile.txt): failed to open stream: Permission denied in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2
錯誤不同的驅動
PHP Warning: fopen(): open_basedir restriction in effect. File(E:\Log
ewfile.txt) is not within the allowed path(s): (C:/Inetpub/vhosts/test.in\;C:\Windows\Temp\) in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2
PHP Warning: fopen(E:\Log
ewfile.txt): failed to open stream: Operation not permitted in C:\Inetpub\vhosts\test.in\httpdocs\Test.php on line 2
只是澄清:代碼運行到'或死(「無法打開文件!」)'「條件」? – VolkerK
@VolkerK是的正確,但我的觀點是如何給php一個文件寫入文件的訪問 – Shaik
爲了調試的目的:你可以使用'或者死(「無法打開文件!」)。var_export(error_get_last(),true)) ;'和[add](http://stackoverflow.com/posts/35865591/edit)輸出到你的問題文本? (也許編輯實際的路徑,如果你覺得它顯示到你的服務器的大部分) – VolkerK