rgb192
asked on
all the files in one folder (and all the files that are in that folder)
<?php
$filesarray = array();
$dirsarray = array();
$folder_location='C:/Users/Acer/Documents/';
if(!is_readable($folder_location))
{
echo "You don't have enough permissions to access this folder!";
die();
}
if ($handle = opendir($folder_location)){
echo "Opened the folder successfully!<br>\n";
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..")
{
if(is_file($folder_location.''.$entry)) {
echo "$entry<br />";
$filesarray[] = $entry;
}
elseif(is_dir($folder_location.''.$entry)) {
echo "$entry<br />";
$dirsarray[] = $entry;
}
}
}
closedir($handle);
}
else
{
echo "There was an error opening the folder!";
die();
}
echo '<pre>';
print_r($filesarray);
print_r($dirsarray);
echo '</pre>';
foreach($filesarray as $key=>$value){
echo $value.'<br>';
}
foreach($dirsarray as $key=>$value){
echo $value.'<br>';
}
?>
this reads all the folders and files in one windows directory
but how to read all the files that are in all the folders in one windows directory
documents
file1
file2
documents/folder1
file1
file2
file3
documents/folder2
file1
file2
documents/folder3
file1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a related question about storage in array
https://www.experts-exchange.com/questions/27999224/store-in-a-directory-files-array.html