Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  103] [ 6]  / answers: 1 / hits: 23807  / 15 Years ago, fri, april 17, 2009, 12:00:00

I have a folder of images, from 10 to 200, a webpage, a jquery fade and a php script that read folder full of images



Is there any way to make the php script scan a folder, get a list of image (in an array ?) and pass it to jquery script ? (first question)



Now, i can make a xml file from the result php list of files found or make a html <li> from the list in the html. is there ANY other way to do that ? (question #2)


More From » php

 Answers
6

To continue on from nickf's excellent answer, this is slightly more robust for images of different types.



$imagesDir = 'path/to/your/images/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);

echo json_encode($images);


There are other ways of doing this, but this is the easiest. Note some file systems are case sensitive, so ensure the extension list is matching precisely what you're after.


[#99693] Friday, April 10, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devane

Total Points: 451
Total Questions: 88
Total Answers: 100

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
;