Insautomatic insertion of images in a div class
Goodmorning everyone,sorry in advance for my poor english…I’m using google translator!
i have this html code of a slideshow. I upload these 4 images from the folder indicated and make the slideshow.
<div id="slideshow"> <img src="photos/image1.jpg" alt="Slideshow Image 1" class="active" /> <img src="photos/image2.jpg" alt="Slideshow Image 2" /> <img src="photos/image3.jpg" alt="Slideshow Image 3" /> <img src="photos/image4.jpg" alt="Slideshow Image 4" /> </div>
I have a webcam that periodically saves images in this folder and therefore I would need to upload them automatically without having to manually insert the lines of code (imageN…until N++). To automate the reading of the images, which are constantly being created, I thought of using this php function to read the images in the photos folder.
<?php function images($dir) { $files1 = scandir($dir); foreach ($files1 as $x=>$value) { if ($value == "." || $value == ".."){ unset($files1[$x]); } } foreach ($files1 as $x=>$value) { echo "<li><img src=\"photos/$value\"></li>"; } } ?>
and to call the function in this way
<div id="slideshow" > <?php images (photos);?> </div>
In manual mode the slideshow works, while in automatic way, with the search of the images through php function, it doesn’t work. Can anyone help me out? Thank you mario