I'm trying to display all videos a webpage using the following code, I've gotten as far as being able to iterate over the files, printing the file names and embedding a video. However the videos are greyed out and don't work, I suspect I did something wrong with using $filename in the code.
<?php
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $filename) {
if (!$filename->isDot()) {
if ($filename != "index.php" and $filename != "error_log") {
echo $filename, "<br>";
echo '<video width="400" controls="controls" preload="metadata">
<source src=$filename type="video/mp4"></video>';
echo "<br><br>";
}
}
}
?>
This is how it shows up: