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>
  • 相关阅读:
    Codeforces 787D. Legacy 线段树优化建图+最短路
    Codeforces 1051E. Vasya and Big Integers
    BZOJ3261 最大异或和
    BZOJ3531 SDOI2014 旅行
    洛谷P2468 SDOI 2010 粟粟的书架
    2018 ICPC 焦作网络赛 E.Jiu Yuan Wants to Eat
    HDU6280 From Tree to Graph
    HDU5985 Lucky Coins 概率dp
    (HDU)1334 -- Perfect Cubes (完美立方)
    (HDU)1330 -- Deck (覆盖物)
  • 原文地址:https://www.cnblogs.com/zhangbaozhong/p/9314813.html
Copyright © 2011-2022 走看看