So I have this working code:
<?php
$folder = './images/';
echo '<form action="" method="post">'."
".'<select name="image">'."
".
dropdown(image_filenames($folder), @$_POST['image']).
'</select>'."
".'</form>';
function image_filenames($dir)
{
$handle = @opendir($dir)
or die("I cannot open the directory '<b>$dir</b>' for reading.");
$images = array();
while (false !== ($file = readdir($handle)))
{
if (eregi('\.(jpg|gif|png)$', $file))
{
$images[] = $file;
}
}
closedir($handle);
return $images;
}
function dropdown($options_array, $selected = null)
{
$return = null;
foreach($options_array as $option)
{
$return .= '<option value="'.$option.'"'.
(($option == $selected) ? ' selected="selected"' : null ).
'>'.$option.'</option>'."
";
}
return $return;
}
?>
This is creating a drop down menu with the contents listed from my /images folder. How to I then post the selected image?