问题:
This question already has an answer here: 这个问题已经在这里有了答案:
- Getting the names of all files in a directory with PHP 15 answers 用PHP 15 获取目录中所有文件的名称 答案
- PHP list all files in directory [duplicate] 5 answers PHP列出目录中的所有文件[重复] 5个答案
What would be the best way to list all the files in one directory with PHP? 用PHP在一个目录中列出所有文件的最佳方法是什么? Is there a $_SERVER function to do this? 是否有$ _SERVER函数可以执行此操作? I would like to list all the files in the usernames/ directory and loop over that result with a link, so that I can just click the hyperlink of the filename to get there. 我想列出usernames /目录中的所有文件,并通过链接遍历该结果,以便我可以单击文件名的超链接到达那里。 Thanks! 谢谢!
解决方案:
参考一: https://stackoom.com/question/14Bi9参考二: List all files in one directory PHP [duplicate]