index.php中有代码:
<select name="select" id="select_invoice">
<option value="">--- Please select ---</option>
<?php echo $obj->printOption(); ?>
</select>
课程如下:
class SelectOption {
private $query_names;
private $selected_index = '';
public function SelectOption($query_names=''){
if($query_names) $this->query_names = $query_names;
if($query_names) $this->query_names = $query_names;
}
public function printOption(){
echo $this->getOption();
}
public function get_diretory($query_names) {
print '<select name="files">';
$directory = dir($query_names) or die($php_errormsg);
print '<option> --Please select-- </option>';
while (false !== ($f = $directory->read())) {
if (is_file($directory->path.'/'.$f)) {
print '<option> ' . $f . '</option>';
}
}
$directory->close();
}
}
$query_names = 'file_directory';
$obj = new SelectOption($query_names);
$obj->get_diretory($query_names);
如何从此选择菜单中获取选项值并在目录中找到文件并读取它?