Search dir using wildcard string, return filename, and loop.
Posted
by Charlie Murphy
on Stack Overflow
See other posts from Stack Overflow
or by Charlie Murphy
Published on 2010-03-12T10:28:22Z
Indexed on
2010/03/12
10:57 UTC
Read the original article
Hit count: 245
Hello all, I'm having some problems, and looking for some help. I'm trying to create a photo gallery in javascript, that will be able to 'update' it's self automatically. I need to be able to search a directory, and grab a file with a specific prefix.
I need to output the followng HTML code:
<li><a href="images/resize_FILENAME.ext"><img src="images/thumb_FILENAME.ext"></a></li>
The 'resize_' and 'thumb_' use a timestamp to identify, so they have the same ending, just a different prefix.
So, for example, if I search the directory for an image with a prefix of 'resize_', I need to insert that into the a tag, and then remove the '_resize' prefix, and add the '_thumb' prefix for the img tag. I then need to be able to do that for each image in the directory.
Any help would be greatly appreciated.
Oh, I should add:
I'm assuming php would be easiest for this, but if an alternative exists that would work too. I'm also using jQuery if javascript would be better.
© Stack Overflow or respective owner