BR
asked on
how to list what is inside a directory using PHP?
Dear Experts,
I use PHP 7 and Linux server
I want to list all the folders and files inside a directory
I want to list it like this:
firstfolder
file1.jpg
file2.jpg
file3.jpg
secondefolder
filename.jpg
filename2.jpg
How can I do that with PHP?
below code works perfectly fine. However it only brings me one folder, I want to see nested folders and what is inside..
thank you
I use PHP 7 and Linux server
I want to list all the folders and files inside a directory
I want to list it like this:
firstfolder
file1.jpg
file2.jpg
file3.jpg
secondefolder
filename.jpg
filename2.jpg
How can I do that with PHP?
below code works perfectly fine. However it only brings me one folder, I want to see nested folders and what is inside..
$handle = opendir(dirname(realpath('myfolder')).'/myfolder/1234/');
while($file = readdir($handle)){
if($file !== '.' && $file !== '..'){
echo '<img src="myfolder/1234/'.$file.'" border="0" />';
}
}
thank you
How many levels? Sounds like you want a recursive solution - but you can end up with a lot of output.
ASKER
I have two levels actually.
I have some folders, and there are some pictures in it...
firstfolder
file1.jpg
file2.jpg
file3.jpg
secondefolder
filename.jpg
filename2.jpg
I have some folders, and there are some pictures in it...
firstfolder
file1.jpg
file2.jpg
file3.jpg
secondefolder
filename.jpg
filename2.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you all