1

By now I'm convinced that I must be one of the few who experienced something like this. The problem is that my PHP is not listing updates (or recent file changes) in a certain directory.

Say I have 3 files: 1.jpg 2.jpg 3.jpg

When I do something like this:

while (false !== ($file = readdir($handle))) {
    echo $file.'<br />';
}

I get:
.
..
1.jpg
2.jpg
3.jpg

Which is expected, but the problem is that when I remove one file I still see the old list of three files. I have checked with Apache by navigating directly to the directory and I do see the new change with just two files in the folder. If I output the image in HTML I get three image-tags but the last one is empty. So no caching going on there with Apache.

I am using MAMP on OSX, I have disabled everything I can think of, so no XCache, no eAccelerator, and also no-cache in the header. I've even tried with clearstatcache() followed by restarting the server / computer, changing from PHP 5.3 to PHP 5.2 then back again.

Last two things I tried, upgraded MAMP to latest version (currently 2.0.1) and cleared all .DS_Store from my localhost but to no avail. I see the updates in Finder, Apache sees them as well, its just PHP that decides to stick to the old version of the folder's contents.

My PHP version is 5.3 with MAMP on OSX Snow Leopard.

Any ideas / suggestions are more than welcome :)

Francis Laclé
  • 384
  • 2
  • 6
  • 22
  • 2
    Are you sure you're looping through the directory you think are? – deceze Jul 25 '11 at 13:26
  • Have you tried different techniques to read the directory? Like: [DirectoryIterator](http://www.php.net/manual/class.directoryiterator.php) – Yoshi Jul 25 '11 at 13:27
  • @deceze that did cross my mind. So I did double check the path. I am storing images in an array. If I remove the folder, I don't get to see the images in Apache but PHP still shows an array with 'ghost' entries inside. – Francis Laclé Jul 25 '11 at 15:35
  • @Yoshi I tried with scandir() but not with DirectoryIterator, I will give that a shot! – Francis Laclé Jul 25 '11 at 15:37
  • @deceze and Yoshi you know sometimes it takes a pair of fresh eyes to look at a problem. Playing with DirectoryIterator prompted me to echo the path and yes deceze was right, the path is wrong. The path is being set by another config file and I didn't check in there lol. Thanks again! – Francis Laclé Jul 25 '11 at 15:50

0 Answers0