doudengjin8251 2016-04-13 08:59
浏览 19

我需要帮助用php + ajax填充3个依赖的动态文件夹下拉菜单

It would be great hep for me if any one can help me, I have a directory with 3 main folders A,B,C and Sub folders A1,A2,A3 in A folder like wise.., When the user select the folder A from 1st drop down,the Second drop down should be populated with sub folders in the Folder A.After Selecting second drop down the third drop down should be populated with sub sub folders on selection of sub sub folder and submit the files has to be displayed on the page with link to open the file. I know this would be done with the help of Ajax call,But i was a starter to php Kindly help me please... Also a alternate approach I have tried using glob function

I dont know whats wrong with the Code no files are displaying in the page..

<?php

Session_start();
Error_reporting(E_ALL & ~E_NOTICE);
$reportname  = $_POST['Rep'];
$year  = $_POST['year'];
$customer  = $_POST['cus'];
$month= $_POST['month'];
$path= ".."."/".$reportname."/".$year."/".$customer."/".$month."/"; 
echo $path ."<br/>";
$files = glob($path."*.xlsx");
foreach($files as $file)
 {
echo $file;
 }
?>
  • 写回答

1条回答 默认 最新

  • dongzhonggua4229 2016-04-13 09:09
    关注
    $("#dropdown1").on("change", function() {
    
      $.ajax({
        url: "phpfile.php",
        type: 'POST',
        data: {
          folder: $(this).val()
        }
        success: function(data) {
          $("#dropdown2").html(data);
        }
      });
    });
    

    In phpfile.php

    $fileslist = scandir($_POST['folder']);
    $str = "";
    foreach($fileslist as $file) {
      if (is_dir($file)) {
        $str. = "<option>$file<option>";
      }
    }
    echo $str;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题