域下的所有可用图像
我想制作一个包含我的域(我的互联网根文件夹)下的所有图像的画廊。所有这些图像都位于不同的文件夹中。 “浏览”所有文件夹并返回图像的最佳方式是什么?
I'd like to make a gallery of all images i have under my domain (my internet root folder). All these images are in different folders. What's the best way to 'browse' through all the folders and return the images?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Google 图片搜索,并将
site: www.mydomainwithimages.com
作为搜索字词这将向您显示所有索引图像。只要您的 robots.txt 文件不排除 Google 抓取工具,这应该是您域中的所有内容。Use Google Image Search with
site: www.mydomainwithimages.com
as the search term and this will show you all your indexed images. This should be everything in your domain as long as your robots.txt file doesn't exclude the Google crawler.看看 opendir 你会想写一个函数在递归循环中调用,该函数可以循环特定目录中的文件,检查文件扩展名并将文件作为数组返回,您将与全局数组合并。
Take a look at opendir you would want to write a function that gets called in a recursive loop, the function could loop through the files in the specific directory, check the file extension and return the files as an array which you would merge with a global array.
取决于托管系统,您可以使用带有 exec 或 passthru 的命令行。
如果您不能做这样的事情,正如 fire 所说,opendir 是可行的方法。
Depends on hosting system, you could use command line with exec or passthru
If you can't do such a thing, as fire said, opendir is the way to go.
我想尝试一下 PHP 的 DirectoryIterator 。
这是未经测试的伪代码,但它应该像这样工作:
如果这不起作用,请不要起诉我,这确实有点来自我的帽子,但使用这样的函数将是最优雅的解决你的问题的方法,恕我直言。
//编辑:是的,这与火指出的基本相同。
I would give PHP's DirectoryIterator a spin.
This is untested pseudo-code, but it should work a little bit like this:
Please don't sue me if this doesn't work, it's really kinda from the top of my hat, but using such a function would be the most elegant way to solve your problem, imho.
// edit: Yeah, that's basically the same as fire pointed out.