• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1001
  • Last Modified:

Files array in Javascript

hi all
i wanat to make a dynamic image collection in Javascript using FileSystemObject for collection a files and generate a Array
anay one tel me ho can i found me absalute path where my .html or .asp file run and how can i call all .gif, .jpg and .bmp file in array
1 Solution
ZvonkoSystems architectCommented:
You cannot see files on user's machine without special security dialog, and even with that only on IE browsers.
Or do you want to see files on server side? That is also not possible from browser side. That has to be scripted on web server side.

Alexey FedorovSoftware developerCommented:

What is your goal? I suppoze, you want to enumerate images in some directory on server side and generate images preload in ASP page?

In order to preload images in HTML-page by means of Javascript, you do not need to know absolute URL of the page. Relative URL is enough.
Implementation and description of the "Image preloader" is available at http://www.webreference.com/programming/javascript/gr/column3/. Article is titled as "JavaScript Image Preloader".

Example of client HTML is at http://www.webreference.com/programming/javascript/gr/column3/2.html.

As you can see, you should generate images relative URLs array by means of script in ASP page: var aImg = [“node.gif”, “plus.gif”, “minus.gif”, “line.gif”, “gap.gif”].

Against of this example, you can put any URLs which you want: absolute or relative of this HTML-page.

For example, var aImg = [“http://som.domain.com/site/images/node.gif”, “plus.gif”, “minus.gif”, “../images/line.gif”, “gap.gif”].

In order to get absolute URL of the current HTML-page on client side, you can use "document.URL" and trim file name from the tail.
In order to get absolute file path on server side use ASP's "MapPath" function. But is returns not an URL, it returns file path which can not be used on client side.

Good luck!
ISKPatelAuthor Commented:
Thanks alexf2
my prb is sloved now..
but one still remain those is " how can i got absolute path of my file?"
e.g: i have a file abc.html and store in "c:\win\abc\" location .. how can i got this lucation in javascript...?
because some time this file rum on diffrent machine or diffrient lucations that y i need this path location information...


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now