获取服务器目录中文件列表的最简单方法 [英] Easiest way to get list of files in the server directory
本文介绍了获取服务器目录中文件列表的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在目录中获取所有图像(或简称所有文件)的数组(例如www.example.com/images/)。我更喜欢使用JavaScript,但很难做到。我应该使用PHP,meybe?
I need to get array of all images (or simply of all files) in directory (e.g. www.example.com/images/). 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.
非常感谢!
推荐答案
Javascript无法获取服务器上的所有文件,因为它是客户端语言。
Javascript cannot fetch all files on a server, as it is a client-side langugage.
http:// php。 net / manual / en / function.glob.php 就是你所需要的。
$all = glob('/path/to/dir/*.*');
$images = glob('/path/to/dir/*.{jpg,png,gif}');
这篇关于获取服务器目录中文件列表的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文