Monday, August 20, 2007

Read Directory Content

Here I will show you how to read a directory Content using php readdir function. Simple
 // Define the full path to your folder from root
$path = "/home/user/public/foldername/";

// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");

// Loop through the files
while ($file = readdir($dir_handle)) {

if($file == "." || $file == ".." || $file == "index.php" )

continue;
echo "
$file
";

}

// Close
closedir($dir_handle);

Advnaced

Copyright Ayon Baidya

No comments:

Post a Comment