script herkent dir niet als dir

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ivar

ivar

16/10/2007 14:28:00
Quote Anchor link
hallo,

dit script:
----
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?
// This is the directory to list files for.
$theDirectory = "dir"; //default: .

//own scandir

$dir = $theDirectory;
$dirlist = scandir($dir);

//print_r($dirlist);

echo "<table><tr><td>type</td><td>name</td><td>dir</td></tr>";
echo "<tr><td colspan='3'align='right'style='color: #FF0000;'>alles</td></tr>";

foreach ($dirlist as $hit){
    $type = filetype($hit);
        $path = realpath($hit);
        
      echo "<tr>";
       echo "<td>".$type."</td>";
      echo "<td>".$hit."</td>";
      echo "<td>".$path."</td>";
      echo "</tr>";
}

echo "<tr><td colspan='3'align='right'style='color: #FF0000;'>alleen dirs</td></tr>";

foreach ($dirlist as $dir){
    if (filetype($dir) == 'dir'){
            echo "<tr><td>map</td><td>".$dir."</td><td>n.v.t.</td></tr>";
                if (($dir !== ".") and ($dir !== "..")){
                //echo "<tr><td colspan='3'>vervolg<td></tr>";
                    $subdirlist = scandir($dir);
                        
                        foreach ($subdirlist as $subhit){
                              $subtype = filetype($subhit);
                                    $subpath = realpath($subhit);
        
                                  echo "<tr>";
                                echo "<td>".$subtype."</td>";
                                echo "<td>".$subhit."</td>";
                                echo "<td>".$subpath."</td>";
                                  echo "</tr>";
                        }                        
                }
        }
}

echo ("</table>");
?>

----
herkent de dir dir_twee niet als dir. wat doe ik fout online voorbeeld --> (http://test.steunpunt.nexethosting.com/)

wie helpt mij?

Ivar

P.S. zijn er ook bb/html tags om een link te maken. (hier op het forum dus)
Gewijzigd op 01/01/1970 01:00:00 door Ivar
 
PHP hulp

PHP hulp

06/11/2024 00:44:16
 
TJVB tvb

TJVB tvb

16/10/2007 14:38:00
Quote Anchor link
voor je 2e vraag:
http://www.phphulp.nl/faq/#4

Je kunt ook is_dir($dir) gebruiken
En doe eens aan error reporting
 
- SanThe -

- SanThe -

16/10/2007 14:38:00
Quote Anchor link
is_dir().
Voor je PS zie de FAQ.
 
Ivar

ivar

16/10/2007 15:12:00
Quote Anchor link
nu heb ik dit:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?
error_reporting(E_ALL);

// This is the directory to list files for.
$theDirectory = "dir"; //default: .

//own scandir

$dir = $theDirectory;
$dirlist = scandir($dir);

//print_r($dirlist);

echo "<table><tr><td>type</td><td>name</td><td>dir</td></tr>";
echo "<tr><td colspan='3'align='right'style='color: #FF0000;'>alles</td></tr>";

foreach ($dirlist as $hit){
    //$type = filetype($hit);
        $type = "file";
        $pretype = is_dir($hit);
        if ($pretype == TRUE){$type = "dir";}
        $path = realpath($hit);
        
      echo "<tr>";
        echo "<td>".$type."</td>";
        echo "<td>".$hit."</td>";
        echo "<td>".$path."</td>";
        echo "</tr>";
        
}

echo "<tr><td colspan='3'align='right'style='color: #FF0000;'>alleen dirs</td></tr>";

foreach ($dirlist as $dir){
    //if (filetype($dir) == 'dir'){
        if ($type == "dir"){
            echo "<tr><td>map</td><td>".$dir."</td><td>n.v.t.</td></tr>";
                if (($dir !== ".") and ($dir !== "..")){
                //echo "<tr><td colspan='3'>vervolg<td></tr>";
                    $subdirlist = scandir($dir);
                        
                        foreach ($subdirlist as $subhit){
                              //$subtype = filetype($subhit);
                                    $subtype = "file";
                                  $presubtype = is_dir($hit);
                      if ($presubtype == TRUE){$type = "dir";}
                                    
                                    $subpath = realpath($subhit);
        
                                  echo "<tr>";
                                    echo "<td>".$subtype."</td>";
                                    echo "<td>".$subhit."</td>";
                                    echo "<td>".$subpath."</td>";
                                  echo "</tr>";
                        }                        
                }
        }
}

echo ("</table>");
?>


maar zie hier het werkt niet.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.