dev_py_uk
dev_py_uk

Reputation: 428

Opening a file from a directory with a directory populated list

I have a drop down list which is populated from a directory on my server, I want to be able to select an item from the list and it will either download or open the file.

This is my code so dfar:

List.php

<div align="center">
<form name="marketingpages">
<select name="menu" onChange="top.location.href=this.options[this.selectedIndex].value;" value="GO" id="marketinglist">
      <option value="" selected="selected">-----</option>
  <?php 
       foreach(glob(dirname(__FILE__) . '/policies/*') as $filename){
       $filename = basename($filename);
       echo "<option value='" . $filename . "'>".$filename."</option>";
    }
?>

</select>
</form>
</div>

When I select an item from the list though I'm just directed to a page where I get the message "Object Not Found" and the URL doesn't contain the sub directory 'policies' which is referenced in the code.

Can anyone help?

Upvotes: 0

Views: 49

Answers (1)

JNF
JNF

Reputation: 3730

You didn't add policies in the option.value. Try this:

echo "<option value='policies/" . $filename . "'>".$filename."</option>";

Upvotes: 4

Related Questions