I have seen another question with the same problem, but with just 1 answer, which didn't worked for me.
The question: PHP scandir - multiple directories
I'm using Joomla! to create my site (I create everything with templates, most that I don't understand creating an extension).
So, I created folder pbfData
in main folder.
In it I created folder users
. But scandir does not detects any of those.
Errors (without if (is_dir)
)
Warning: scandir(/pbfData/) [function.scandir]: failed to open dir: No such file or directory in [...]/pbf/index.php on line 61
Warning: scandir() [function.scandir]: (errno 2): No such file or directory in [...]/pbf/index.php on line 61
Fatal error: Cannot access empty property in [...]/pbf/index.php on line 61
The code looks like this:
class users {
var $users;
function refUsers() {
$dir = '/pbfData/';
if (is_dir($dir)) {
$this->$users = scandir($dir);
} else {
echo "<b>CRITICAL ERROR: </b>No access to users directory.";
}
}
[...] }
It outputs
CRITICAL ERROR: No access to users directory.
(Note: adding is_dir
to solve it was answer to the other question, but as I have written it doesn't work for me.)