php怎么检查某个文件夹下是否有可写权限

php怎么检查某个文件夹下是否有可写权限,第1张

php检查某个文件夹下是否有可写权限

/**

 * 检查目录是否可写

 * @access public

 * @param  string $path 目录

 * @return boolean

 */

public function checkPath($path){

    if (is_dir($path) || mkdir($path, 0755, true)) {

        return true

    }

    return false

}

Check director is writable recursively. to return true, all of directory contents  must be writable

<?php

function is_writable_r($dir) {

    if (is_dir($dir)) {

        if(is_writable($dir)){

            $objects = scandir($dir)

            foreach ($objects as $object) {

                if ($object != "." && $object != "..") {

                    if (!is_writable_r($dir."/".$object)) return false

                    else continue

                }

            }    

            return true    

        }else{

            return false

        }

        

    }else if(file_exists($dir)){

        return (is_writable($dir))

        

    }

}

?>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11825043.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存