php scandir()函数 参数不能用url作为参数嘛?

php scandir()函数 参数不能用url作为参数嘛?就是这个函数只能本地路径无法用url作为参数! 因为这边有一个服务器上放css js image 等文件 所以需要去这边取。 请问大家有什么好的遍历url下的文件嘛

阅读 3.4k
3 个回答

PHP文档中有一段话:

Tip
A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

也就是,配置中如果打开了fopen wrappers的话,可以使用URL作为参数。

是取某个web 服务器url下所有的文件列表?
如果是的话, 原则上讲是没这功能的.
没有服务器自带scandir这个函数的功能的.

不过有些比较类似的功能,
比如apache设置过Options +Index
nginx设置过autoindex
访问目录的时候, 会把目录下的文件给列出来.
但肯定不是你想像的那些数据.

如果是自己的服务器, 可以在目录下面放个Php文件专门提供列出文件列表的功能.

如果是别人家的服务器, 那没有办法.

不可能遍历远程url的目录的。。。那还有啥安全可言

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题