php - 浏览另一台服务器 PHP 文件夹中的文件

标签 php file

我有两台服务器。一个用于文件,一个用于网站。

我想出了如何将文件上传到该服务器,但现在我需要在网站上显示缩略图。

有没有办法使用 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/

相关文章:

php - 避免在循环期间连续显示空列

php - 在单元测试中模拟被测试的对象是不是很糟糕?

php - 序列化添加意外数据

python - 在python中将txt文件保存为二进制文件

file - React-Native - 本地文件的路径

php - 如何并排排列图像

javascript - 如何进行 AJAX 调用 - Elgg

php - 我在哪里保存 Zend_Form 文件?

c++ - 写入临时文件

删除一行的 C 代码