www.webdeveloper.com
Results 1 to 6 of 6

Thread: Can Javascript Reading the contents of a folder ??

  1. #1
    Join Date
    May 2007
    Posts
    7

    Can Javascript Reading the contents of a folder ??

    Can Javascript Reading the contents of a folder ??
    --------------------------------------------------------------------------------

    Ok here is my question

    Can javascript read the contents of a folder and list its path name in a array

    Here is what i have so far
    Code:
    @echo off
    if '%1'=='w' (
    echo Scenary[%items%]='images/Scenary/%2'; >> array_it.js
    set /a items=items+1
    ) else (
    echo Scenary=[]; > array_it.js
    set /a items=0
    for %%p in (*.jpg, *.gif, *.png) do (
    call %0 w %%p
    )
    set items
    set items=
    )
    That is my bat file that create a js file with the array of path names for the images


    Code:
    
    Scenary=[]; 
    Scenary[0]='images/Scenary/DSCN2103.jpg'; 
    Scenary[1]='images/Scenary/DSCN2113.jpg'; 
    Scenary[2]='images/Scenary/DSCN2114.jpg'; 
    Scenary[3]='images/Scenary/DSCN2129.jpg'; 
    Scenary[4]='images/Scenary/DSCN2131.jpg'; 
    Scenary[5]='images/Scenary/DSCN2135.jpg'; 
    Scenary[6]='images/Scenary/DSCN2136.jpg'; 
    Scenary[7]='images/Scenary/DSCN2137.jpg'; 
    Scenary[8]='images/Scenary/DSCN2232.jpg'; 
    Scenary[9]='images/Scenary/DSCN2234.jpg'; 
    Scenary[10]='images/Scenary/DSCN2395.jpg'; 
    Scenary[11]='images/Scenary/DSCN2399.jpg'; 
    Scenary[12]='images/Scenary/DSCN2414.jpg'; 
    Scenary[13]='images/Scenary/DSCN2448.jpg'; 
    Scenary[14]='images/Scenary/DSCN2510.jpg';
    As you can see That works great

    Now i going to put a image upload thing for the owners of the site to upload their new pictures to certain folders on the server.

    now here is the problem

    I want to run the bat file everytime a new image is add to the folder so i can get the update js array so that the new image that had been uploaded is on the web page

    Is there any way to do this
    all the html and displaying of images i can do i just need to know how to make that .bat file run everytime a new image is added
    or is there a easier way to do this.
    I know php script can do this but i never done anything in php so i know nothing about it

  2. #2
    Join Date
    May 2007
    Posts
    7
    anybody???? any help would be great thanks !!

  3. #3
    Join Date
    Jun 2007
    Posts
    5

    Try this

    <div id='IdDetailsHost'><script id='IdDetailsScript' type='text/undefined' src='Details.html' language='undefined' defer='true'></script></div>

    function LoadIt() {
    document.all.IdDetailsHost.innerHTML = document.all.IdDetailsScript.text
    }

    in your .bat file of course you need to use this name. Maybe this would work if name was yours too-i did not test...

  4. #4
    Join Date
    May 2007
    Posts
    7
    i dont get it where do i put this code

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    You put that code in Internet Explorer 4. Don't use such code for anything more modern because most browsers wont understand such obsolete code.

    For info on how to load additional JavaScript files from within your JavaScript code see http://javascript.about.com/library/bladdjs.htm

  6. #6
    Join Date
    Jun 2007
    Posts
    5

    Try tact

    I just wrote that code a couple of weeks ago without looking it up elsewhere. I don't consider it obsolete.

    As a suggestion, try more tact like this:

    Yes this code might work, but here is a better way...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles