Listing all of the files in a folder / If file is image, display a preview
I have the following code:
echo "<table> <tr>";
function listFolderFiles($dir){
$ffs = scandir($dir);
$c = 0;
foreach($ffs as $ff){
$c++;
if($ff != '.' && $ff != '..'){
$extensions = array(".png",".jpg",".jpeg",".bmp",".gif","");
foreach($extensions as $extension) {
if(stripos($ff, $extension)) {
// file is an image, give a preview
}
}
echo '<td style="padding:20px; border: 1px solid
lightgray;"><img src="'.$ff.'">'.$ff;
if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
echo '</td>';
}
if($c >= 5) { $c = 0; echo "</tr> <tr>"; }
}
}
listFolderFiles('files/martin');
Basically, what im trying to do is:
List all files and folders
If file is an image, display a image preview
If file is an audio format, display a preview using the html5 tag
I'm stuck with the last 2 steps, can anyone help?
No comments:
Post a Comment