Skip to content Skip to sidebar Skip to footer

Fetch Images From Folder

I have the following code that fetches images from Flickr, and I want to change it to fetch images from a folder (without the Flickr API). I need help. I don't know how to do it. v

Solution 1:

To fetch image from a folder, you may be use ajax/jquery if want javascript.

Here I've done this using PHP. You can test this also.

<?php 
$imagesDir = 'images\\';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);

foreach($images as $key=>$value)
{
  echo "<img src='$value' style='margin:10px'>";
}
?>

There is an folder called images. Then fetch the images using the php glob function.

Note : Code is tested and working in my site


Post a Comment for "Fetch Images From Folder"