PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

PHP Based MP3 Music Directory

PHP Music Directory

This single file script will display all mp3 music files from directory and display song names and file size while you can play song by a link too. Just place this script in directory containing mp3 music files and browse script by local or online server.

<table ALIGN=CENTER BGCOLOR=#ffffff CELLPADDING=4 CELLSPACING=0 BORDER=2>
<tr><th>File</th><th>Size</th></tr>
<?php
$dir="./";
if (is_dir($dir)) {
$fd = @opendir($dir);
while (($part = @readdir($fd)) == true) {
if ($part != "." && $part != "..") {
$file_array[]=$part;
}
}
if ($fd == true) {
closedir($fd);
}
}
sort($file_array);
reset($file_array);
for($i=0;$i<count($file_array);$i++) {
$npart=$file_array[$i];
if (strstr($npart,".mp3")) {
$name=str_replace(".mp3","",$npart);
$fsize=filesize($npart)/1000;
print("<tr><td><a href=\"$npart\">$name</a>");
print("<td>$fsize</td></tr>");
}
}
?>
</table>

Download Script

  • Share/Bookmark
Tags: , ,
Posted in: Directory, Useful Scripts
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




Post a Comment

  Subscribe Via RSS
  Subscribe Via Email