Dynamic Folder Listing

J

Joseph

Hi,

Is there a way to use Javascript to generate content dynamically based
on the files that are in a specific folder in my website? Basically,
i'd like to create a document folder and as i add documents have
javascript update my page to show the documents available.
 
E

Erwin Moller

Joseph said:
Hi,

Is there a way to use Javascript to generate content dynamically based
on the files that are in a specific folder in my website? Basically,
i'd like to create a document folder and as i add documents have
javascript update my page to show the documents available.

Hi,

Javascript cannot read the contents of a directory on your server.
However, if the directory is reachable via http, JavaScript could for
instance read an indexfile (which you must make) that lists the files in
there.

I would advise you to go serverside (eg PHP) to make such a listing in
realtime, which is very easy.

In case you don't have a serverside language, and your content isn't
updated a lot, you can, of course, update that indexfile by hand every
time you add/remove a file.


Regards,
Erwin Moller
 
E

Erwin Moller

Erwin said:
Hi,

Javascript cannot read the contents of a directory on your server.
However, if the directory is reachable via http, JavaScript could for
instance read an indexfile (which you must make) that lists the files in
there.

I would advise you to go serverside (eg PHP) to make such a listing in
realtime, which is very easy.

In case you don't have a serverside language, and your content isn't
updated a lot, you can, of course, update that indexfile by hand every
time you add/remove a file.


Regards,
Erwin Moller

One addition: It is possible for most webservers to allow directorylistings.
eg:
http://www.example.com/yourdir/
would then result in a directorylisting.

You could parse this using AJAX for example.

Going serverside is much easier however.

Regards,
Erwin Moller
 
T

Thomas 'PointedEars' Lahn

Joseph said:
Is there a way to use Javascript to generate content dynamically based
on the files that are in a specific folder in my website?
Yes.

Basically, i'd like to create a document folder and as i add documents
have javascript update my page to show the documents available.

You could use XMLHttpRequest, for example.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,369
Latest member
FTMZ

Latest Threads

Top