1

I have the following code to list all files (in the direct folder and sub folders).

$imagesDir = '../Stock_Images';
$di = new RecursiveDirectoryIterator($imagesDir);
foreach (new RecursiveIteratorIterator($di) as $filename => $file)
{
    echo $file->getPathname() . '<br/>';
}

The problem is that I have 2 files named ".apdisk" and ".DS_Store".
The script list both of the files and then stops like there's a bug or something.
I deleted one of the files and then it worked as it should....

Any idea why it happens and how to fix that?

Thanks

EDIT:
I also had FOLDER named ".TemporaryItems" < dont ask me why.
It was the problem >

Caught exception: RecursiveDirectoryIterator::__construct(../Stock_Images/.TemporaryItems/folders.501): failed to open dir: Permission denied

just deleted that folder and it fixed the problem.

Ron
  • 3,975
  • 17
  • 80
  • 130
  • [enable error reporting](http://stackoverflow.com/questions/6575482/php-how-do-i-enable-error-reporting) and tell us if there is any errors – Gordon Apr 30 '13 at 15:18
  • but you just said that you had two files there. it would have to stop no? I'm sure I'm missing something. Did you try getting a try/catch block around the foreach, just to check? – MeTitus Apr 30 '13 at 15:18
  • @marco I have 2 files with just extension in their name. The rest are regular. – Ron Apr 30 '13 at 15:22
  • 1
    @Ron the try/catch is always a good starting point. – MeTitus Apr 30 '13 at 15:26

0 Answers0