i'd been trying to make a project which is a simple file manager that list all files and allows you to do everything that a file manager does , so I first wrote the below script for listing the files which was the initial phase , I ran the below script on my server and it was working fine the scripts are :
<?php
if ( $handle = opendir('/home1/myusername') )
{
echo "Directory handle: $handle\n";
echo "Entries:\n";
/* This is the correct way to loop over the directory. */
while ( false !== ( $entry = readdir( $handle ) ) )
{
echo "$entry\n";
}
}
?>
but when I change the directory to just "/home1" it wouldn't list any files I mean when i make the below change :
<?php
if ( $handle = opendir('/home1') )
{
echo "Directory handle: $handle\n";
echo "Entries:\n";
/* This is the correct way to loop over the directory. */
while ( false !== ( $entry = readdir( $handle ) ) )
{
echo "$entry\n";
}
}
?>
while when I go in this directory via ssh putty , and do ls , I get my username directory ..
i am just wondering why opendir() failed to do so ? and is there any solution or any other function which i can use in replace to that ?