Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery pull images from directory

Is it possible to pull a bunch of .jpg pictures form a local file and throw them into a list? Sorry, I was very vague

Pulling from a directory (relitive to the index) like.

I want to list them in an image tag, sequentially.

like image 575
Kevin Brown Avatar asked May 13 '09 22:05

Kevin Brown


2 Answers

You could use the following to dynamically create an image and append it to a list.

$('<img />')
    .attr('src', 'FOLDER LOCATION HERE')
    .appendTo('#mylist')

some quick searching led me to find a FileSystemObject ( ActiveX =( ) to search a folder for files.

here is a link: http://www.codeproject.com/KB/scripting/search_in_files.aspx

but if you are doing any server side processing (.net, php, whatever) that would be the best way to figure out what images are available to you to display on the page. (so if you could clarify)

like image 189
Jon Erickson Avatar answered Oct 02 '22 02:10

Jon Erickson


Are you saying you have a local text file filled with the locations of images?

<?php
$handle = fopen("localfile.txt", 'r');

echo '<ul>';
while ($line = gets($handle)) {
    echo '<li><img src="' . $line . '"/></li>';
}
echo '</ul>';

fclose($handle);
?>
like image 43
Charles Avatar answered Oct 02 '22 02:10

Charles