Skip to content

Easiest way to get list of files in the server directory

I need to get array of all images (or simply of all files) in directory (e.g. I prefer to use JavaScript but it’s hard to make. So should I use PHP, meybe?

Could you please help me – I’m not good at this.

Thank you very much!


Javascript cannot fetch all files on a server, as it is a client-side langugage. is what you need.

$all = glob('/path/to/dir/*.*');

$images = glob('/path/to/dir/*.{jpg,png,gif}');