What I want to do is simple, but since I'm just starting out in PHP, I'd like your help.
I want to read a directory for available files and then get the filenames and put them in a drop down list.
Whatever the user will select will be the value of the variable $selected.
I already found the code to read directories:
My guess is that the whole trick would be to use something like
inside the loop, where $cnt is a counter used to add a number to each new option for the list.
The result should be a form with the list and a "Select" button beside it.
Can someone help me put it together?
Thanks in advance.
I want to read a directory for available files and then get the filenames and put them in a drop down list.
Whatever the user will select will be the value of the variable $selected.
I already found the code to read directories:
Code:
function list_files() { global $the_path; $handle = dir($the_path); print "\n<b>Uploaded files:</b><br>"; while ($file = $handle->read()) { if (($file != ".") && ($file != "..")) { print "\n" . $file . "<br>"; } } print "<hr>"; }
Code:
$cnt=++; <option value="$cnt">$file</option>";
The result should be a form with the list and a "Select" button beside it.
Can someone help me put it together?
Thanks in advance.
Comment