Skip to content

Instantly share code, notes, and snippets.

@nileshk
Created October 29, 2011 04:17
Show Gist options
  • Save nileshk/1324066 to your computer and use it in GitHub Desktop.
Save nileshk/1324066 to your computer and use it in GitHub Desktop.
JSON list of images in current directory
<?php
/*
JSON list of all images files in current directory
*/
$dir = ".";
$dh = opendir($dir);
$image_files = array();
while (($file = readdir($dh)) !== false) {
$match = preg_match("/.*\.(jpg|png|gif|jpeg|bmp)/", $file);
if ($match) {
$image_files []= $file;
}
}
echo json_encode($image_files);
closedir($dh);
?>
@afsatechnical
Copy link

how to convert all image from dir to base64 list in json format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment