Jump to content

directory help


sasori

Recommended Posts

i made a test code that will show all the .php files in the directory, but how come when i try to

open a different directory, it only shows the "index.php" when there are a number of php files in that directory, does this means, i should run the script in the same directory on which i want the files to be listed?

 

<?php
$directory = "../test2/";
$opendirectory = opendir($directory);
while($filename = readdir($opendirectory))
{
      $filepath = $directory.$filename;
       if(is_file($filename) && ereg("\.php$",$filename);
      {
          $gallery[] = $filepath;
      }
sort($gallery);
foreach($gallery as $file)
{
    echo "<br/>";
    echo $file."<br/>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/117137-directory-help/
Share on other sites

I wouldn't think so. Try specifying the full directory path.

$directory = "../test2/";

 

including the root directory

 

same.. it only shows the index.php alone

 

these are the directories inside my wamp www root folder

 

-test    <-- am trying to display the .php files inside this folder but it only shows /test/index.php alone

-test2  <-- this is where my scrip resides

-php

 

 

i tried different variations for the $directory

 

$directory = "C:/wamp/www/test/";

$directory = "/www/test/";

$directory = "../www/test/";

$directory = "../test/";

 

but still, it doesn't show the other files..only the index.php of the test folder

Link to comment
https://forums.phpfreaks.com/topic/117137-directory-help/#findComment-602476
Share on other sites

Archived

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

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