i'm working in application in php, that gets all files in a folder, and list the files in a table likes this
<?php
// open this directory
$myDirectory=opendir("./server/".$_SESSION['username']."/".$_SESSION['nomepc']."/Tasklist/");
$mdir = "server/".$_SESSION['username']."/".$_SESSION['nomepc']."/Tasklist/";
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount = count($dirArray);
Print (intval($indexCount)-2 ." Imagens <center><a href='downloadsFicheiros/downloadTasklist.php'>Fazer downloads Tasklist</a></center>");
sort($dirArray);
print("<TABLE class=table>\n");
print("<TR><TH>Filename</TH><th>Eliminar<button onclick='confirmaApaga()'>Apagar tudo</button></th><th>Ficheiro Criado em</th></TR>\n");
for($index=0; $index < $indexCount; $index++) {
$tiraExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $dirArray[$index]);
$str = str_replace("foto_", "", $tiraExt);
if (substr("$dirArray[$index]", 0, 1) != "."){
echo('<TR><TD><a data-toggle="modal" data-target=".bs-example-modal-sm"><img height="80" width="120" src="img/txtFile.png"</a></td>');
print("<td>");
echo('<a href="apagarFicheiros/tasklist/apagarFicheiroTasklist.php?ficheiro='.$dirArray[$index].'"><button class="btn btn-danger"> Apagar Ficheiro</button></a>');
print("</td>");
print("<td>");
$filename = "$mdir/$dirArray[$index]";
if (file_exists($filename)) {
echo date ("d F Y H:i:s.", filemtime($filename));
}
print("</td>");
print("</TR>\n");
}
}
print("</table>\n");
?>
this show us a table with the files inside the folder. now, i create a div modal in bootstrap and i call the modal in table
div bootstrap
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<?=print( "<img height='480' width='720' src='$filename'")?> </div>
</div>
</div>
call the modal in php
echo('<TR><TD><a data-toggle="modal" data-target=".bs-example-modal-sm"><img height="80" width="120" src="img/txtFile.png"</a></td>');
and when I click in the txtFile.png shows the modal but instead of showing the right image its shows the last image of the table.