KaptainBlazzed Posted September 15, 2010 Share Posted September 15, 2010 I have a script the iterates through my directories allowing users to transverse and download files. It was up and running just fine until i switched servers, both were running PHP 5.x.x and ISS 7. The issue is no matter what directory i run the script in, the DirectoryIterator returns a bunch of "." or a "$Recycle.Bin" if i set it to the look in "C:/" Here is the code: <? $cwd = "c:/"; foreach (new DirectoryIterator($cwd) as $file) { echo $file->getFilename(). "\n"; } ?> Here is the output from "C:/" $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin $Recycle.Bin Here is the output if is set $cwd to "." . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I can not figure this out and am beginning to think it is a permissions issue. any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/ Share on other sites More sharing options...
Andy-H Posted September 15, 2010 Share Posted September 15, 2010 Wouldn't that be because C:\ is underneith the public directory and you can't 'serve' these files? Try getcwd Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111480 Share on other sites More sharing options...
KaptainBlazzed Posted September 15, 2010 Author Share Posted September 15, 2010 getcwd() returns the following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I have tried it in several different directories, including my web root and it always returns the same result, a bunch of "." i do however get a different # of "." depending on the directory. Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111481 Share on other sites More sharing options...
ignace Posted September 16, 2010 Share Posted September 16, 2010 Try that and postback the output: $dir = new DirectoryIterator(dirname(__FILE__)); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot()) { var_dump($fileinfo->getFilename()); } } Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111611 Share on other sites More sharing options...
KaptainBlazzed Posted September 16, 2010 Author Share Posted September 16, 2010 Try that and postback the output: $dir = new DirectoryIterator(dirname(__FILE__)); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot()) { var_dump($fileinfo->getFilename()); } } No output because they are all "." This is really starting to bug me and i can not figure it out. Could it be a setting in the config file? Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111648 Share on other sites More sharing options...
mikosiko Posted September 16, 2010 Share Posted September 16, 2010 this work for me: <?php $path = 'C:/TEST/'; foreach (new DirectoryIterator($path) as $fileInfo) { if($fileInfo->isDot()) continue; echo $fileInfo->getFilename() . "<br>\n"; } ?> You should look at RecursiveDirectoryIterator too http://php.net/manual/en/class.recursivedirectoryiterator.php Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111683 Share on other sites More sharing options...
KaptainBlazzed Posted September 16, 2010 Author Share Posted September 16, 2010 After some more research, i believe it is a permissions issue. The old server was running on Windows 7, and the new one is Server 2008 r2. Not sure how to fix it, any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/213521-directoryiterator-not-working-help/#findComment-1111733 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.