Drop down list populated from file directory, help required!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pj15
Forum Newbie
Posts: 1
Joined: Fri Feb 26, 2010 10:57 am

Drop down list populated from file directory, help required!

Post by pj15 »

Over to the experts,
I have spent a while trying to customize and produce some code, after many hours of searching google for hints and snippets, this is what it does so far.

-Displays files in a drop down list from the "uploads" directory.
-Uses java script to remove a value from the list.

What I would like to be able to do and I need to no if its "doable" is;

- make the links to files active (so the document will open when selected, maybe with the aid of a button would be nice), I have seen this with a download button but cannot figuer out how to implement it.

- once a user has removed a value from the list, to remove the file from the "uploads" directory and no just the list.

Is this possible, if not, are there other ways to achieve this.
Appreciate your help guys.

Code:

<?php
$dir = opendir('location');
echo '<select id="mySelect">';

while ($read = readdir($dir))
{

if ($read!='.' && $read!='..')
{
echo '<option> <a href="files/'.$read.'">'.$read.'</a></option>';
}

}

echo '</select>';

closedir($dir);
?>
<input type="button" onclick="formAction()" value="Delete">
</form>
Post Reply