Drop down list populated from file directory, help required!
Posted: Fri Feb 26, 2010 11:12 am
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>
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>