0
請幫我,我如何加載文件夾中的文件,我剛纔在一個目錄中,上一個PHP下拉列表?Dropdownlist文件夾文件php
現在我有這樣的代碼,但不工作...
<form action="" method="post">
<select name="seleccionArchivo">
<?php
$dir = $_GET["/Repositorio"];
$files = scandir($dir);
// Prepare the select box to echo
echo "<select name=\"files\">";
foreach ($files as $file)
{
// Return files only
if (is_file($dir. $file))
echo "<option value=\"$file\">$file</option>";
}
echo "</select>";
?>
</select>
<input type="submit" value="Ir al examen">
</form>
是否打印錯誤?如果是這樣,請分享它們。 – Sakknekedro
允許GET參數直接列出用戶的磁盤上的任何文件是非常危險的。過濾某些目錄或設置一個基本目錄來工作。 –
更改'$ dir = $ _GET [「/ Repositorio」];'到'$ dir = $ _GET [「Repositorio」];' –