Robert Granlund
asked on
PHP list folders
I have a piece of script that is incomplete. What I want to do is list all the folders in a drive. Be able to click on the folder to display the content of that folder (which is music) and then click on the song so it will play.
This is as far as I have got:
This is as far as I have got:
<ul>
<?php
$dir = "D:/Music/";
$files = scandir($dir);
foreach($files as $ind_file){
?>
<li><a href="<?php echo $dir."/".$ind_file;?>"><?php echo $ind_file;?></li>
<?php
}
?>
</ul>
Obviously on line 31 you would do something like
$dir_list = getDirectoryList($dir);
foreach ( $dir_list as $k=>$v)
{
echo "{$v}<br />";
}
ASKER
@maeltar:
Thanks this makes a nice list. However, how can I click on a folder name and have it open and display, in a list, all the files?
Thanks this makes a nice list. However, how can I click on a folder name and have it open and display, in a list, all the files?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure if that is what you are meaning....
Found something that may meet you needs (after reading them correctly)
Demo
http://www.evoluted.net/stuff/
Source
http://www.evoluted.net/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip
Demo
http://www.evoluted.net/stuff/
Source
http://www.evoluted.net/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip
ASKER
That works great. Now all I have to do is figure out how to link the file so if it is an mp3 it will play. Any further ideas?
That will be platform dependant, you click the mp3, it will download it and use the local player.
You could use some flash/jQuery to play the files..
http://plugins.jquery.com/plugin-tags/sound
You could use some flash/jQuery to play the files..
http://plugins.jquery.com/plugin-tags/sound
Another nice tuto on doing this..
http://www.premiumbeat.com/tech-blog/how-to-make-an-html5-music-player-using-the-audio-tag/
http://www.premiumbeat.com/tech-blog/how-to-make-an-html5-music-player-using-the-audio-tag/
Open in new window