我有两台服务器。一个用于文件,一个用于网站。
我想出了如何将文件上传到该服务器,但现在我需要在网站上显示缩略图。
有没有办法使用 PHP 遍历文件服务器上的文件夹/files 并在网站上显示这些文件的列表?
我搜索了一段时间,但找不到答案。 我尝试使用 scanddir([URL]),但没有用。
最佳答案
我不好意思这么说,但我在另一篇文章中找到了我的答案:
PHP directory list from remote server
function get_text($filename) {
$fp_load = fopen("$filename", "rb");
if ( $fp_load ) {
while ( !feof($fp_load) ) {
$content .= fgets($fp_load, 8192);
}
fclose($fp_load);
return $content;
}
}
$matches = array();
preg_match_all("/(a href\=\")([^\?\"]*)(\")/i", get_text('http://www.xxxxx.com/my/cool/remote/dir'), $matches);
foreach($matches[2] as $match) {
echo $match . '<br>';
}
关于php - 浏览另一台服务器 PHP 文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15924839/