I want to display files present in the public folder(sites/default/files). So in the module file when I click on a link it will call to js function, How can I get all file names which are present in the public folder in js file.
It depends where you are storing all your files, to use the base url of your site you need to do this:
If your files are inside some theme:
If you are using files with public://, use this:
$uri = $your_file_name; // Example "public://xxx" $path= file_create_url($uri);
I hope it works in your case