Jump to content

Listing Directory into a javascript array! Help Pls!


Recommended Posts

So i pass 2 variables to a js function. Image Source and the Image Name.

 

I want to use the image name to know what image i should show to the user first but i need to use the image source in order to look into a specified directory, find all the files that exist there and place all the filenames into a javascript array.

 

function showgallery(imgsrc,img)
  {
         // Do some fancy stuff to show Large Photo here... (this part i can do)
         
         // Get Directory listed and placed into array so that i can do previous / next photo changing. --- THIS PART I NEED HELP WITH
  }

 

Thanks Much!

You cannot do this with javascript. You have to use server-side script to get a list of files in directory on server and output it to the client (in the form of a js array or whatever).  You can do it on page load or use ajax to make a request to server-side script to get a listing and return results.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.