2014-08-28 166 views
1

我想要和刪除目錄和文件用PHP腳本的mkdir權限被拒絕PHP腳本

例如:

<?php 
if (!is_dir('examples')) { 
    mkdir('examples'); 
} 
?> 

,但我得到許可被拒絕。我怎樣才能讓這個腳本運行這些命令? 我試過chmod 777 mkdir.php和chmod + s mkdir.php 它擺脫了權限被拒絕的方法,但它仍然不會創建文件夾。

我怎樣才能讓mkdir()和/或rmdir()php函數工作?

請注意,我沒有使用PHP作爲shell腳本。

+1

它不是你不必擔心它允許腳本的權限您要在其中創建新文件夾的文件夾。 – 2014-08-28 21:05:48

+0

您可能需要chmod新文件夾將要的父目錄。所以,如果你有'/ var/www/test/foo',並且你想要製作'/ var/www/test/foo/bar',你需要chmod'/ var/www/test/foo' – 2014-08-28 21:05:59

+0

chmod呢? – j0h 2014-08-28 21:07:03

回答

1

可能只是給用戶播放。 (我只是來這裏放一個答案,以紀念「答案找到」) 原文:

 
777, if the user www-data isn't the owner of the parent directory or not in the same group as the owner. Usually it would be 775, tho. 

信用夏洛特杜諾瓦