j0nr Posted May 10, 2011 Share Posted May 10, 2011 Hi folks, First time posting here and a bit of a novice at PHP, but am learning.... I am fiddling with a small bit of code to create a very basic php gallery (I'm sure everyone has at some point). I started off with a mysql intergrated one then thought I would try a new one without the mysql. Its working fine but I am just having one very strange problem. Basically, I started of with just /mygallery/index.php?w=... where ... = the location (physical folder) of photos. I use opendir to open the contents of w= and parse whether it is a directory or a file (then narrow it down to just images). If it is a dir, then I present it as a link to that folder (sub-album) if it is a photo, I present a thumb link to the image. Now I have added a mod_rewrite rule to allow my urls to be of the form 'mygallery/album/subalbum' this gets ocnverted into 'mygallery/index.php?w=album/subalbum' Now the funny bit. If I create a new folder in one of the subalbum, e.g. : mygallery/album/subalbum/<b>New Folder</b> the code works. i.e. when I point my browser at 'mygallery/album/subalbum' I get a link showing 'New Folder' But if I create a new folder of any other NAME it does not appear in the list!! So if I just rename 'New Folder' to 'New Folde' it drops of the web page!!! Now I am really not sure what the hell is going on... Hope someone can help. I will post my code if necessary. Thanks in advance! Jon Reynolds Quote Link to comment https://forums.phpfreaks.com/topic/235997-odd-bahaviour-with-opendir-and-readdir/ Share on other sites More sharing options...
j0nr Posted May 10, 2011 Author Share Posted May 10, 2011 Maybe I should add that this is currently running on Windows using XAMPP, but is to be uploaded to my Linux Server. Quote Link to comment https://forums.phpfreaks.com/topic/235997-odd-bahaviour-with-opendir-and-readdir/#findComment-1213276 Share on other sites More sharing options...
salathe Posted May 10, 2011 Share Posted May 10, 2011 I will post my code if necessary. That sounds like a good idea, preferably a snippet that is short but shows what is going on. Quote Link to comment https://forums.phpfreaks.com/topic/235997-odd-bahaviour-with-opendir-and-readdir/#findComment-1213283 Share on other sites More sharing options...
j0nr Posted May 10, 2011 Author Share Posted May 10, 2011 Ah got it! readdir() does not return the full path, so adding the path and results of readdir() to is_dir() made it work.... Why 'New Folder' showed up but none of the other folder will remain a mystery to me.... Quote Link to comment https://forums.phpfreaks.com/topic/235997-odd-bahaviour-with-opendir-and-readdir/#findComment-1213288 Share on other sites More sharing options...
salathe Posted May 10, 2011 Share Posted May 10, 2011 readdir() does not return the full path, so adding the path and results of readdir() to is_dir() made it work.... That is by far the most common issue that people run into when using readdir. Glad you got it sorted. Quote Link to comment https://forums.phpfreaks.com/topic/235997-odd-bahaviour-with-opendir-and-readdir/#findComment-1213290 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.