• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to get all files names in a direcotry

Dadparvar

Well-known member
#1
Hi,

In my add-on, there is folder, that in it, again there is folder with for each user (folder's name is user's id)

Now, in a template, there is js code that gets the directory of each user's dedicated folder and then, in an array, gets the name of all files names inside the folder and show them in profile page of user.

For example: I uploaded 10 files in my own folder. So, the js gets the directory with this code:
Code:
            this.sources    = {
                mp3    : 'styles/default/dadparvar/test/files/{$user.user_id}/' + this.name + '.mp3',
                ogg    : 'styles/default/dadparvar/test/files/{$user.user_id}/' + this.name + '.ogg'
            };
and in my profile page, in a tab, it shows them using this code (it gets an array):
Code:
[ 'song1', 'song2', 'song3', 'songx' ]
You see I have 4 files uploaded in my own directory.

Now the question is: how can I get those files names in that structure (array) automatically using js? Now as you see I manually wrote those names.

Thanks in advance