Jump to content


This topic is now archived and is closed to further replies.


php directories on windows

Recommended Posts

i consider myself quite experienced at php... but am having a nervous breakdown on something real stupid.

I installed an emulator on a windows computer, and am trying to use php scripts on the pc.

so i do this:
$path = "C:\Documents and Settings\blablabla\Desktop\TEST\\";
$myDirectory = opendir($path);
while($entryName = readdir($myDirectory))
so far so good. I get a list of the directories within $path.
[0] => .
[1] => ..
[2] => 640x800
[3] => 800x600
[4] => 800x800
[5] => BuffMonster
[6] => deleteemptydirs.bat
[7] => formato_immagini.bat

foreach($dirs as $value){

if($value!="." && $value!="..")
  echo $path.$value."\\<br>";
   echo "is a directory<br>";
   echo readdir($mydirectory2)."<br>";;
   while(($dir_name = readdir($mydirectory2)) !== FALSE);
    echo "  ".$dir_name."<br>";
   print "<hr>";
and here i can't get thru...

it prints: is a directory<br>
this part: [code]echo readdir($mydirectory2)."<br>"; [/code] prints a .
and this part : [code]echo "  ".$dir_name."<br>";[/code] just prints

It wont tell me whats inside dir... I'm guessing the problem is that windows uses \ instead of /
so i have to use "\\" each time and i can get confusing... but this should be so simple can't figure out why it doesn't work...
please help!!!

Share this post

Link to post
Share on other sites
I have windows and the slash doesn't seem to be a factor

Here is the code I use to read a directory

$dir = "c:/Inetpub/wwwroot/phpforum/pdffiles";
if ($handle = opendir($dir)) {
   while (false !== ($file = readdir($handle))) {
        // This gets rid of the . and ..
        if (ereg("[a-z]", $file)){
                  print '<a href="path/to/files/'.$file.'">'.$file.'<a><br />';

Works for me fine


Share this post

Link to post
Share on other sites


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.