我有这段代码来获取文件的名称并将它们添加到下拉列表中:
<?php
$dir = "uploads";
$dh = opendir($dir);
echo "<select name=case>";
while (($file = readdir($dh)) !== false) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$name = (pathinfo($file, PATHINFO_FILENAME));
if ($file != "." && $file != ".." && $ext == "jpg")
{
echo "<option value=".$dir."/".$file .">" . $name . "</option>";
}
}
echo "</select>";
closedir($dh);
?>
现在我想添加一个提交按钮并从同一页面的下拉列表中打印所选项目的文件路径(值) 。