递归Chmod无法使用PHP [英] Recursive Chmod not working PHP

查看:113
本文介绍了递归Chmod无法使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的PHP函数,该函数应该递归chmod我服务器上的目录之一。

I have the below PHP function that should recursively chmod one of the dir's on my server.

由于某种原因,它不起作用-我知道目录的路径是正确的,因为我已经使用一个快速脚本进行了测试,该脚本只打印出该目录中的文件。

For some reason it's not working - i know the path to the dir is correct as i've tested it with a quick script that just prints out the files within that dir.

$root_tmp = '/tmp/mixtape2'; 
chmod_r($root_tmp);

function chmod_r($Path) {
$dp = opendir($Path);
while($File = readdir($dp)) {
  if($File != "." AND $File != "..") {
     if(is_dir($File)){
        chmod($File, 0777);
        chmod_r($Path."/".$File);
     }else{
         chmod($Path."/".$File, 0777);
     }
  }
closedir($dp);
}

有任何想法吗?

推荐答案

chmod($Path.'/'.$File, 0777);

您必须输入chmod的完整路径

You must put full path to chmod

这篇关于递归Chmod无法使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆