PHP scandir 的 url

Roy*_*718 2 php url scandir

如何将 scandir 与 URL 一起使用。现在看来 PHP 并没有将 URL 视为 URL。有没有办法在 scandir 中使用 URL?

<form action="new_exercise.php?id=<?php echo $new_id; ?>" method="post">
        <input class="" type="text" name="name_exe" required placeholder="Project naam">
        <select name="audio" required>
          <option></option>
          <?php
          $path = 'URL comes here';
          $results = scandir($path);
          foreach ($results as $result) {
              if ($result === '.' or $result === '..') continue;

              if (is_dir($path . '/' . $result)) {
                  echo "<option>" . $result . "</option>";
              }
          }
          ?>
        <select>
        <input class="btn-success" type="submit" name="submit" value="Maak nieuwe opdracht">
    </form>
Run Code Online (Sandbox Code Playgroud)

max*_*xhb 6

这不可能。scandir()和许多其他文件操作只能在本地进行。

如果您想获取远程服务器上的文件列表,那么您需要在服务器上有一个脚本/API 来返回该文件列表。

试想一下,如果您可以读取远程计算机上的所有文件和目录,会发生什么?安全性确实会受到损害。