Jump to content

problem with getting directory listings


Recommended Posts

I'm using the latest version of XAMPP on Windows and can't figure out why I'm not seeing the correct directory listing when using the scandir() function.  The first time i opened the web page I got the correct listing of what was in the directory.  After moving and adding files, I opened the web page again and got the same listing I had before i moved and added files.  Is this the correct spot to ask this or should I use the XAMPP support forums?

I tried

$path= 'C:\\xampp\\htdocs\\website\\img\';
$listing = scandir($path);
print_r($listing);

I had 5 files in the 'img' directory the first time I opened the website and got the correct listings.  I then added 10 new files and moved 2 files out and refreshed the page and got the same listings of the original 5 files. I closed and reopened the browser  and tired again and got the original 5 files again.  

 

Link to post
Share on other sites

No.

\ is the escape character so needs to be \\ in a dir path.

The final \ also needs to be \\ as it is currently escaping the quote at the end of the string.

Easier is to use / in paths (even on windows)

Link to post
Share on other sites
5 hours ago, Barand said:

No.

\ is the escape character so needs to be \\ in a dir path.

The final \ also needs to be \\ as it is currently escaping the quote at the end of the string.

Easier is to use / in paths (even on windows)

Yes, or the DIRECTORY_SEPARATOR constant, which is equivalent to '/'

Link to post
Share on other sites

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.