要用php对两个文件和一个目录进行改属性,但不知道为什么没成功改到属性function filemod($modno=0777)
{
chmod("/robots.txt",$modno);
chmod("/sitemap.xml",$modno);
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("/userfiles/"), RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $item) 

    chmod($item,$modno); 

}

解决方案 »

  1.   

    确认执行 php文档的帐号具备对这个文档进行chmod 的权限.
      

  2.   

    robots.txt 文件用于限制蜘蛛访问的范围,通常应放在网站根目录中你 /robots.txt 把它放在文件系统的根目录中,显然是不对的
      

  3.   

    参考:http://topic.csdn.net/u/20120524/15/66901291-258d-44e4-8d0f-267f8e9f57a3.html
      

  4.   

    我只能通过FTP客户端对目录手动来改,这样很不方便 
      

  5.   

    php限制使用了chmod, 使用umask后再使用chmod
    $old = umask(0);
    chmod("/path/some_dir/some_file.txt", 0755);
    umask($old);
      

  6.   

    没用是因为你执行命令的权限不够.
    不需要umask.只要一切正常php能够正常的修改权限.
      

  7.   

    chmod好像只能改变文件的权限吧,不能改变文件夹的权限。
    @exec("sudo chmod -R 755 /path/some_dir/some_file.txt");