Files array in Javascript

Posted on 2005-04-26
Last Modified: 2012-06-21
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
Question by:ISKPatel
    LVL 63

    Expert Comment

    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.


    Accepted Solution


    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 Article is titled as "JavaScript Image Preloader".

    Example of client HTML is at

    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 = [“”, “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!

    Author Comment

    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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now