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>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题