Hey.
I'm trying to open a dir under safe mode.
and i keep getting this error :
Fatal error: Uncaught exception 'RuntimeException' with message 'DirectoryIterator::__construct() [<a href='directoryiterator.--construct'>directoryiterator.--construct</a>]: Unable to access /home/mypath/mysite.com/public_html/path/to' in /home/mypath/mysite.com/public_html/site/loaddir.php:7 Stack trace: #0 /home/mypath/mysite.com/public_html/site/loaddir.php(7): DirectoryIterator->__construct('/home/mypath...') #1 {main} thrown in /home/mypath/mysite.co/public_html/site/loaddir.php on line 7
my question is :
is there a way i can open a dir under safe mode?
or maybe my code is wrong?
$root = $_SERVER["DOCUMENT_ROOT"];
$path = "/path/to";
$allowed = array('jpg','gif','bmp');
$iterator = new DirectoryIterator($root.$path);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile()) {
$path = $fileinfo->getPathname();
$filename = $fileinfo->getFilename();
$info = pathinfo($filename);
$ext = $info['extension'];
$filename_noext = basename($filename,'.'.$ext);
if (in_array($ext, $allowed)){
echo "$filename_noext\n";
}
}
}
Help?