I'm using a php video gallery from codeboxx in an attempt to see all the videos my security camera is uploading to my hosting. My camera makes many subfolders for dates and hours which I can't keep anticipating. What I've been trying to get is for this script to include subfolders:
<body>
<div id="vid-gallery"><?php
// (A) GET ALL VIDEO FILES FROM THE GALLERY FOLDER
$dir = __DIR__ . DIRECTORY_SEPARATOR . "gallery" . DIRECTORY_SEPARATOR;
$videos = glob($dir . "*.{webm,mp4,ogg}", GLOB_BRACE);
// (B) OUTPUT ALL VIDEOS
if (count($videos) > 0) { foreach ($videos as $vid) {
printf("<video src='gallery/%s'></video>", rawurlencode(basename($vid)));
}}
?></div>
</body>
I think I can get the first part to work in scanning 4 subfolders deep by me doing this:
$dir = __DIR__ . DIRECTORY_SEPARATOR . "{gallery,gallery/**,gallery/**/**,gallery/**/**/**,gallery/**/**/**/**}" . DIRECTORY_SEPARATOR;
Now I think this line is giving me a problem as I can't seem to get this src get videos in the subdirectories and wildcards don't seem to work:
printf("<video src='gallery/%s'></video>", rawurlencode(basename($vid)));
I've tried to look up how to do it and I've seen array/echo/recursive functions, but I don't know how to implement anything. I appreciate any help.