Jump to content

Odd, directory read issue...


iPixel

Recommended Posts

Here's my directory read code..

$dir = "renamed/";
$fileCount = 0;


// Open the directory, and proceed to read its contents
if (is_dir($dir))
	{
	if ($dh = opendir($dir)) 
		{
			while (false !== ($file = readdir($dh)))
				{
					$fileCount++;
					echo $file . "<BR>";
				}
			closedir($dh);
		}
	}

 

That part works 99%, for some reason the echo $file . "<BR>"; part echos two weird things.

A singe dot and two dots as displayed below.

 

R_334499.jpg

R_334488.jpg

R_334510.jpg

R_334479.jpg

R_334494.jpg

R_334476.jpg

R_334480.jpg

R_334507.jpg

R_334482.jpg

R_334489.jpg

R_334498.jpg

..

R_334509.jpg

R_334511.jpg

R_334513.jpg

R_334483.jpg

R_334514.jpg

R_334484.jpg

R_334504.jpg

R_334506.jpg

R_334475.jpg

R_334502.jpg

R_334490.jpg

R_334486.jpg

R_334477.jpg

R_334492.jpg

R_334487.jpg

R_334493.jpg

.

R_334496.jpg

R_334500.jpg

R_334485.jpg

R_334497.jpg

R_334491.jpg

R_334481.jpg

R_334508.jpg

R_334505.jpg

R_334501.jpg

R_334503.jpg

R_334495.jpg

R_334478.jpg

R_334512.jpg

 

Any idea where it's getting the  ..    and the    .        from?

Link to comment
Share on other sites

How can i avoid $file containing such a thing, i want to use those filenames to do other things with them, and clearly a file named ..  and  .  will not be found.

I guess i could just check if $file == "." skip it but i'm just curious if there's a way around this.

 

Thanks!

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.