drwkqwa82140 2015-11-09 14:25 采纳率: 0%
浏览 19
已采纳

从具有目录填充列表的目录中打开文件

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?

  • 写回答

1条回答 默认 最新

  • dsxjot8620 2015-11-09 14:29
    关注

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

    echo "<option value='policies/" . $filename . "'>".$filename."</option>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?