【发布时间】:2016-03-07 09:34:10
【问题描述】:
如何使用带有 URL 的 scandir。现在看起来 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>
【问题讨论】:
-
我当然希望scandir不允许这样做
-
我很确定你不能用 url 做到这一点。 scandir 函数接受相对或绝对的目录路径,但您不能将 URL 传递给此函数。这是不可能的。