Jump to content

Odd bahaviour with opendir and readdir


j0nr

Recommended Posts

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

Link to comment
Share on other sites

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....

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.