joomla - PHP scandir doesn't work -


i have seen question same problem, 1 answer, didn't worked me.

the question: php scandir - multiple directories

i'm using joomla! create site (i create templates, don't understand creating extension).

so, created folder pbfdata in main folder. in created folder users. scandir not detects of those.

errors (without if (is_dir))

warning: scandir(/pbfdata/) [function.scandir]: failed 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 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 users directory.";     }   } [...] } 

it outputs critical error: no access users directory.

(note: adding is_dir solve answer other question, have written doesn't work me.)

is_dir not solution directory path, checks if file directory or not. path can use jpath_site or jpath_base etc inside joomla. joomla comes built in constants. have here https://docs.joomla.org/constants .

your code be

$dir = jpath_base."/pbfdata", 

Comments