php recursive directory search working for webcams
Posted: Fri 27 Feb 2015 12:17 pm
http://www.warrandytefarm.com/test/getimagenames.php
the code is below for anyone who wants one that works on php4+
now I have that's going (and its a real pain to do so), I need to filter by camera number and date, probably using drop downs but I get kind of stuck there.
its been a lot of headaches trying to get all the recursive stuff to work
webcams is a subdirectory of the root from where the script is run
another one getimages.php will give the images using the same code but there's a lot of them and i don't want to blow peoples bandwidth
There is probably also a much better way of doing this using glob functions or similar but I cant convince my hosting people to get away from php4
I have used the filenames Cam1_ cam2_ etc and the dates are the main folder names apart from a few rogues that have crept in there.
the code is below for anyone who wants one that works on php4+
Code: Select all
<?php
/**
* @author Rob France
*/
$myfile = new RecursiveDirectoryIterator("webcam/");
$display = Array ('jpeg', 'jpg' );
foreach(new RecursiveIteratorIterator($myfile) as $file)
{
if (in_array(strtolower(array_pop(explode('.', $file))), $display))
/** echo "<img src='" . $file . "'width='600' height='400'><br/> \n";
uncomment the above to display the images */
echo $file . "<br/> \n";
}
?>its been a lot of headaches trying to get all the recursive stuff to work
webcams is a subdirectory of the root from where the script is run
another one getimages.php will give the images using the same code but there's a lot of them and i don't want to blow peoples bandwidth
There is probably also a much better way of doing this using glob functions or similar but I cant convince my hosting people to get away from php4
I have used the filenames Cam1_ cam2_ etc and the dates are the main folder names apart from a few rogues that have crept in there.