zoukankan      html  css  js  c++  java
  • 0715PHP练习:文件操作

    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
        <script src="../0622/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <style type="text/css">
        li{
            height: 20px;
            width: 100px;
            background-color: lightslategrey;
            border: 1px solid gainsboro;
        }
        li:hover{
            cursor: pointer;
        }
        .wjj{
            height: 20px;
            width: 100px;
            background-color: goldenrod;
            border: 1px solid gainsboro;
        }
    </style>
    <body>
        <?php
            $lujing = empty($_GET['lj'])?"../bootstrap":$_GET['lj'];
            //第一次打开获取不到传值,定义文件的开始路径
            $fj = dirname($lujing);
            //找到当前路径的父级路径
            $fj = ($fj == ".")?"..":$fj;
            //当父级路径是当前路径(.)时,改为根目录(..)
            $ziyuan = opendir($lujing);
            //打开文件夹路径获取资源
            echo "<ul><li class='wjj' bs='$fj'>返回</li>";
            while($nr = readdir($ziyuan)){
                //读取资源
                if($nr == '.' || $nr == '..') continue;
                //跳过当前路径和根目录
                if(is_dir("{$lujing}/{$nr}")){
                    //区分文件夹和文件
                    echo "<li class = 'wjj' bs = '{$lujing}/{$nr}'>".$nr."</li>";
                }else{
                    echo "<li>".$nr."</li>";
                }
            }
            echo "</ul>";
            closedir();
            //关闭文件夹
        ?>
    </body>
    </html>
    <script type="text/javascript">
        $(".wjj").click(function(){
            var lj = $(this).attr("bs");
            window.location.href = "wenjian.php?lj="+lj;
            //点击时刷新页面并传值,改变路径
        })
    </script>
  • 相关阅读:
    java JSONObject
    android 8.0 悬浮窗 最简demo
    使用adb 命令(atrace)抓起systrace的方法。
    使用python处理selenium中的获取元素属性
    使用adb/Linux获取网关ip
    Requests text乱码
    python-uiautomator2
    adb命令 判断锁屏
    缓存穿透、缓存击穿与缓存雪崩
    ReentrantLock重入锁详解
  • 原文地址:https://www.cnblogs.com/zhangbaozhong/p/9314813.html
Copyright © 2011-2022 走看看