i am new to yii and i need to get a list of files inside a directory outside of the system folder. i tried it with
$fileListOfDirectory = array();
$pathTofileListDirectory = Yii::app()->request->baseUrl.'/path/to/files';
foreach( new DirectoryIterator($pathTofileListDirectory) as $file) {
if( $file->isFile() === TRUE && $file->getBasename() !== '.DS_Store' && substr(strrchr($file->getPathname(), '.'), 1) == 'txt') {
array_push($fileListOfDirectory, $file->getBasename());
}
}
but I allways get the error
DirectoryIterator::__construct(/myYiiInstallation/system/path/to/files) [directoryiterator.--construct]: failed to open dir: No such file or directory
from the line
foreach( new DirectoryIterator($pathTofileListDirectory) as $file) {
So is there another way to get the list of files or what should I do? thnx!