SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Preload Entire Image Directory

    Hi,

    Does anyone have a code snippet that would preload and entire directory (and sub-directories)?

    I'm using a basic JS array to load individual images but was hoping I could find a more scaleable/efficient way of doing it?

    Code:
    var yourImages = new Array("images/1.jpg", "images/2.jpg")
    Thanks,

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    DK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ilalonde

    As far as I know JS cannot read files in a folder because of security reasons. There is a ActiveX control for IE called FileSystemObject. But only IE = No good, AND I guess it can work only on a local pc, not on a server...

    But, I could use such a script to load all images in a server folder om a server too, so if anybody have any suggestions...


    BTW: I have a little trick that kan make life easier avoiding typing all file names into a script:

    If you have the images saved in a folder on your pc and OS = Windows, run a command prompt (Start -> Run -> cmd <Enter>), navigate to the folder where the images are saved and type "dir *.jpg /b > imagesdir.txt" and <Enter>. The output of the dir command is then saved in the file imagesdir.txt in the same folder instead being written on the screen. Open the file in e.g. Notepad and copy the files names to your script and add " , etc. Easy and less risk of typos!

    Michael

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not possible without some cooperation on the server side. Javascript alone is unable to read server directories, let alone directory trees.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •