我在lubuntu上運行Apache服務器,並試圖使用php編寫用戶可以下載的文本文件。我更改的權限爲這樣:php創建文件的權限
sudo chmod 775 /var/www -R
但是,當我執行腳本我仍然得到一個錯誤:
警告:FOPEN(3):未能打開流:權限在 /VAR否認第217行的/www/myPage.php無法打開文件!
這裏是PHP代碼:
$filename = $liste[0][0];
$fh = fopen($filename, "x+") or die("Could not open file!");
fwrite($fh, "foo") or die("Could not write to file");
fclose($fh);
我是否需要更改其他權限?還是有另一種方法來做我想做的事情? 謝謝
嘗試通過上右擊,以檢查該文件夾的permision。你會看到寫權限不存在/ –
'ls -l/var/www/myPage.php'的結果是什麼?哪個用戶和組擁有該文件? – Aurel
嘗試使用絕對路徑寫入文件。 [fopen-perm-denied](http://stackoverflow.com/questions/3882244/php-fopen-permission-denied) –