I have a PHP script that needs to check the permissions on a directory to make sure it is writable. What I have so far is:
$perms = substr(sprintf('%o', fileperms($folder)), -4);
if ($perms == "0777" || is_writable('temp'.DS))
{
//code here
}
Is this a sufficient check?
PHP’s
is_writable()should be sufficient. Below is the description from the PHP manual:See http://php.net/manual/en/function.is-writable.php for more details.