本文介绍了网址的PHP scandir的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将scandir与URL结合使用.现在看来,PHP无法将URL视为URL.有没有办法在scandir中使用URL?
How can I use scandir with an URL. Now it looks like PHP doesn't see the URL as an URL. Is there a way to use an URL in scandir?
<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()
和许多其他文件操作仅在本地工作.
This is not possible. scandir()
and many other file operations only work local.
如果要获取远程服务器上的文件列表,则需要在服务器上返回该文件列表的脚本/API.
If you want to get a list of files on a remote server then you need a script/API on the server that will return that file list.
试想一下,如果您可以读取远程计算机上的所有文件和目录,将会发生什么?安全性确实会受到损害.
Just imagine what would happen if you could read all files and directories on a remote machine? Security would be realy compromised.
这篇关于网址的PHP scandir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!