Saturday, April 18, 2009

Using javascript to scan a local directory and display files in web browser?

How can I use javascript to scan a local directory and display the files in the browser as if it were really a directory listings page? I could manually make a directory listings page but I would like something that would automatically update itself when new files are added to the directory. I%26#039;m using a free web hosting service for a current project and would very much like the directory listings page but the host does not allow PHP. Please do not suggest other hosts or to manually make the page. If you can tell me how to use javascript to complete this task, please let me know. Thanks!
Using javascript to scan a local directory and display files in web browser?
There is no way to %26quot;read%26quot; a directory using javascript. You can%26#039;t even read a file with javascript. I wish you could.
Using javascript to scan a local directory and display files in web browser?
Do you mean a directory on the server? Just don%26#039;t put an index.html file or anthing else that would be displayed by default, and make a link to the directory, ie: http://your.server.tld/filedirectory/





If you mean on the user%26#039;s computer, there should be no way unless the browser has a security bug.
Reply:javascript runs on the local client computer and not the web server, therefore will only be able to view local files. To view files on the web server, you need a server side script such as asp,php, asp.net etc. I don%26#039;t think there is a way around this one. You can try to enable directory browsing for a folder, disable default pages (index.htm etc), then have a page in another folder show the contents of the browsible folder in a frame or iframe.


No comments:

Post a Comment