English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I know with javascript you can create an array and fill it with pictures.

What I want is the array to build itself based on all the pictures in the folder of type .jpg. I do not want to have to tell it what the name of the picture is, just to pick up all the pictures in that folder.

Any one know how?

2007-05-29 20:19:06 · 2 answers · asked by Tasm 6 in Computers & Internet Programming & Design

2 answers

I've spent considerable time doing just that!
the trick is to read the index page from the directory that is built when you go to a folder without an index.html page.
using ajax.

My Puppy's site is based on this.

http://jpassoc.com/junior ... not a single hard coded image on the entire site. just code to get folders of files.

2007-05-30 04:24:00 · answer #1 · answered by jake cigar™ is retired 7 · 2 0

Do you mean that you want to build a web page that would do this with jpg files in a folder on the client (user's) computer? Or are the files in a folder on the web server?

If you're thinking of the first instance, then there's no viable way. You could do it using special Microsoft extensions so that it would work on some Windows computers, but only if the user grants way more permission than is safe to do.

If you're thinking of the second instance, with the files on the web server, then you can't do it with Javascript (unless you have a server-side Javascript environment installed, like SpiderMonkey, on the web server). You have to use server programming, not client programming. You could do it with PHP, for example, or ASP.NET.

For the second instance, there are also some more complicated ways that combine server-side and client-side programming. You could use PHP to build the file list and populate a Javascript object collection. Then you would use client-side Javascript to create the array from the objects. You could even use Ajax techniques to populate the array. But there would always have to be some server-side component that actually builds the file list.

2007-05-29 20:30:04 · answer #2 · answered by Anonymous · 1 3

fedest.com, questions and answers