Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count number of files in a folder through javascript

Tags:

javascript

I have folder in which there are no. of html files. Can i count the no. of files using javascript? Please help

Thanks

like image 829
Pankaj Khurana Avatar asked Aug 12 '09 12:08

Pankaj Khurana


2 Answers

No, this is not possible using JavaScript only.

You can make an Ajax call to a page and from the server side code you can find the number of files in a folder and then return the result to the callback function.

I assume the files are in not in the client machine.

like image 72
rahul Avatar answered Nov 04 '22 05:11

rahul


Javascript is a client side language. This means that it has no interaction at all with the server. It get sends unprocessed by the server to the client and the client executes it.

However, what you could do is learn AJAX - if you don't know it yet - and create a script (PHP, ASP, Perl, SSI, etc.) that counts the files in the directory and prints the number - I recommend Perl - .
Each minute, for example, the AJAX page would fetch the response of the script and display it.

like image 25
T0xicCode Avatar answered Nov 04 '22 04:11

T0xicCode