How to detect access denied with PHP on Windows?

Asked

Viewed 52 times

2

I’m listing Windows directories with scandir() of PHP and some directories like "System Volume Information", "Documents and Settings" among others have access denied to listing when trying to open, as could do a function to test whether or not the directory has access by returning a variable true or false?

1 answer

3


Yes, you can use is_readable($caminho) to test whether the user used to run PHP has access to a file or directory.

Example (from the manual):

$filename = 'test.txt';
if (is_readable($filename)) {
    echo 'The file is readable';
} else {
    echo 'The file is not readable';
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.